tcsh read command ......?


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users tcsh read command ......?
# 1  
Old 02-11-2005
MySQL tcsh read command ......?

i have just started to use the tcsh shell as a sort of personal challenge since I see so many users using other shells than just bash...
I have written a spcript that is quite lengthy but it is in bash shell and gives an error message in tcsh shell so I cut the script in half and basically revamped it so that it would work with the tcsh shell. here's the code:
#!/bin/bash
#_tclear
while :; do
function fun { clear; pwd; date; tty; }
echo "enter term"
read term
if [ "$term" == "c" ]
then
fun
elif [ "$term" == "z" ]
then
fun
echo "konsole"
find -noleaf -type f -newer './date.file' -fls .specs1 -print | xargs ls -ali --color | sed 's/\.\/.*\///' | more
elif [ "$term" == "s" ]
then
echo "Terminal"
ls -ali $* --color | more
else
fun
echo "Terminal"
ls -ali --color
fi
if [ "$term" == "e" ]
then
fun
echo "Terminal"
ls -ali --color
exit
fi
done
exit 0
this worked fine after some fiddeling.. but it is not tcsh compliant and has a basic error to it. to apply tcsh compliance to the shell script I must change the read command to a tcsh read command .. i tried several commands
>| term
<< term
$_ term
$_=term
to no avail and have not been able to decipher the tcsh man pages yet... there are probably 100 different errors in the script as it is, if I am to get it posix compliant which I would like to do a step at a time to gain the experience that I need to shell script properly..
my one question is what is the read command symbol or syntax in tcsh...
any help would greatly be appreciated..
thanx moxxx68
# 2  
Old 02-11-2005
Most of us don't write scripts in csh (or its desendants). To understand why, read:
Csh Programming Considered Harmful

From that document
Quote:
1b. Reading Files
In the csh, all you've got is $<, which reads a line from your tty. What if you've redirected stdin? Tough noogies, you still get your tty, which you really can't redirect.
# 3  
Old 02-11-2005
CPU & Memory

thanx for your reply and for the pointer.....
moxxx68
# 4  
Old 02-12-2005
MySQL

Quote:
Originally Posted by Perderabo
Most of us don't write scripts in csh
absolutely correct

Last edited by Phantom; 02-12-2005 at 05:10 AM..
# 5  
Old 02-21-2005
tcsh's read command is $<, you could use it like this:
set inputline = $<
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Tcsh script - sed command for special characters

Hi, I am using sed command to replace following line in gz file- sed -n 's/""COS_12_TM_1" ( 1101110101001001010011110100000010110100010010000000100000000010XX010000000 )"/""COS_12_TM_1" ( 110111010100100101001111MM00000010110100010010000000100000000010XX010000000 )"/g' filename.gz $x=... (4 Replies)
Discussion started by: Preeti Chandra
4 Replies

2. UNIX for Dummies Questions & Answers

Tcsh command for assigning output of awk to variable

Hi I have a text file with 2 values and I am trying to assign each value to a variable and then write those to text files. So if the textfile is data.txt with 2 values x and y I want to assign mean=x, and stdev=y and then write these out in text files alongwith the id ($id has already been... (6 Replies)
Discussion started by: violin
6 Replies

3. Shell Programming and Scripting

Read from file and execute the read command

Hi, I am facing issues with the below: I have a lookup file say lookup.lkp.This lookup.lkp file contains strings delimited by comma(,). Now i want to read this command from file and execute it. So my code below is : Contents in the lookup.lkp file is : c_e,m,a,`cd $BOX | ls cef_*|tail... (7 Replies)
Discussion started by: vital_parsley
7 Replies

4. UNIX for Dummies Questions & Answers

read command - using output from command substitution

Hey, guys! Trying to research this is such a pain since the read command itself is a common word. Try searching "unix OR linux read command examples" or using the command substitution keyword. :eek: So, I wanted to use a command statement similar to the following. This is kinda taken... (2 Replies)
Discussion started by: ProGrammar
2 Replies

5. Shell Programming and Scripting

running zsh command in tcsh

Hi all is there a way to run zsh commands in a tcsh shell thanks (3 Replies)
Discussion started by: ab52
3 Replies

6. UNIX for Dummies Questions & Answers

Problem with xterm & tcsh & sourcing a script in a single command

Hi friends, I have a script that sets the env variable path based on different conditions. Now the new path variable setting should not done in the same terminal or same shell. Only a new terminal or new shell should have the new path env variable set. I am able to do this only as follows: >cd... (1 Reply)
Discussion started by: sowmya005
1 Replies

7. UNIX for Dummies Questions & Answers

command substitution with tcsh

I was trying to modify my .cshrc file so that the full path would always be displayed in my command prompt. After doing a search, I was able to accomplish this by adding these lines to my .cshrc file: alias setprompt 'set prompt="%/% "' setprompt alias cd 'chdir \!* &&... (1 Reply)
Discussion started by: Special_K
1 Replies

8. UNIX for Dummies Questions & Answers

at crontab tcsh setenv: command not found

i have written a script "master.shell" which is in the path: /a/homes.surrey.ac.uk/pgt_fs_002/bl00001/phd/griddata/shell/master.shell ==================================== #/usr/local/bin/tcsh setenv GLOBUS_LOCATION /grid/software/globus3 setenv PATH... (1 Reply)
Discussion started by: binbintriangel
1 Replies

9. UNIX for Dummies Questions & Answers

assigning (numeric) command output to var tcsh

Hello, I'm trying to assign a numeric value that is returned from one of my programs to a variable in tcsh. I want to do: @ r10 = './my_prog file 35' where ./my_prog file 35 returns a decimal value, but this doesn't work. How do I achieve the desired result? Janet (4 Replies)
Discussion started by: psran
4 Replies

10. Shell Programming and Scripting

How to combine "find" command in for each loop (tcsh)

Hello I was wandering if I can combine find command in side for each loop in unix the main propose is to change some thing in files from several types and not all of them is this possible ? (on liner script? ) tnx for the helppers (3 Replies)
Discussion started by: umen
3 Replies
Login or Register to Ask a Question