csh and the set command


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers csh and the set command
# 1  
Old 03-02-2004
csh and the set command

Hi, I am trying to write a csh script that will run another csh script, but redirect the output from the second script to an email. my code looks like this.

#!/bin/csh
## This script is designed to run the SSM.sh
## then email the output to a specified email address
## it will also display output to the screen using dtpad.

clear

## Set the file name to the date-time of creation.
set [file_name [ = `date '+SSM_Log%y%m%d.%H%M%S'` ] ]
set [dte_tm [ = `date '+%e %b %T %Y %n'` ] ]

## Test to see that both variables have been passed to the script.
if ("$1" = "" || "$2" = "") then
echo "This script requires at least two parameters"
echo "Example: S04 int10749.ssm"
exit
endif
## Accept variable(s) from the command line
while ( "$1" != " " )
echo "Processing of" $1$2 "completed." > $HOME/${file_name}.txt
echo $dte_tm >> $HOME/${file_name}.txt
echo " " >> $HOME/${file_name}.txt
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" >> $HOME/${file_name}.txt
echo " " >> $HOME/${file_name}.txt
# SSM.sh $1 $2 >> $HOME/${file_name}.txt # second script
echo " " >> $HOME/${file_name}.txt
echo "=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=" >> $HOME/${file_name}.txt
dtpad $HOME/${file_name}.txt
echo ""
echo "Email output file? \c"
set yesno $<
if ("$yesno" = "Y" || "$yesno" = "y") then
cat $HOME/${file_name}.txt | mail bogus.email@dont.eventhinkaboutit.com
else if ("$yesno" = "N" || "$yesno" = "n") then
end
rm -i $HOME/${file_name}.txt
else
echo "Try entering something that makes sense!!!!"
endif
shift
shift
rm -i $HOME/${file_name}.txt
end
Smilie
# 2  
Old 03-02-2004
You don't really state what your problem is....but in looking at your script, you don't use the correct syntax on many of your commands:

set yesno $<
will give a Syntax error.

Change to
set yesno=$<

In the if statement that follows the yesno, you don't end it correctly and don't have the correct syntax for "$yesno" == "Y"

It almost looks like you are trying to convert ksh to csh in some of the statements (or learning both at the same time).
# 3  
Old 03-02-2004
Correct I was trying to convert a ksh script to a csh script.

And getting a lot of syntax errors.

The main error I was getting was the use of "Set"

when setting a variable i.e.
set file_name="`date '+SSM_Log%y%m%d.%H%M%S'`"

in ksh it is;
file_name=`date '+SSM_Log%y%m%d.%H%M%S'`

I do most of my scripting in ksh, and so I am not so familiar with csh.

But as you see I have found the error of my ways.

Thanks for the feedback.
Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

If command in csh

hi everyone what is difference between "if ( -e Arch )" and "if ( -e ./Arch )" in csh shell? Many Thanks samad (1 Reply)
Discussion started by: abdossamad2003
1 Replies

2. Shell Programming and Scripting

How to set variable permanent in csh?

We are using csh on our AIX platform, if we have to export/set a specific environment variable we use setenv command but its only valid till session. How do we set that variable permanent in our csh AIX? Do we put it in userprofile file or something else? (1 Reply)
Discussion started by: aixusrsys
1 Replies

3. Shell Programming and Scripting

Csh , how to set var value into new var, in short string concatenation

i try to find way to make string concatenation in csh ( sorry this is what i have ) so i found out i can't do : set string_buff = "" foreach line("`cat $source_dir/$f`") $string_buff = string_buff $line end how can i do string concatenation? (1 Reply)
Discussion started by: umen
1 Replies

4. UNIX for Dummies Questions & Answers

How to get value from set of values in csh

Hello. In csh if I declared a variable to be a set of arguments can I retrieve a particular element from that set. My code set files=(`ls`) and I want to get only one file from $files. How can I do that????(It is just an abstract example):wall: Thanks in advance :) (5 Replies)
Discussion started by: FUTURE_EINSTEIN
5 Replies

5. Shell Programming and Scripting

csh shell script 'set' argument limit?

Hi , I have a script that is causing a problem that led me to think if there is a limit to the number of arguments for 'set' command in csh shell script. Here is my script: #!/bin/csh -f set top = design_top #1 set v_mbist = ( sim_mbist/*.v ) #2 set v_simlist = ( -v... (2 Replies)
Discussion started by: return_user
2 Replies

6. HP-UX

What is the use of command set -- and set - variable?

Hi, I am using hp unix i want to know the use of the following commands set -- set - variable thanks (4 Replies)
Discussion started by: gomathi
4 Replies

7. Shell Programming and Scripting

tcsh/csh: set prompt in production to color red

Hi folks This is our prompt at the moment oracle@pinkipinki:/opt/oracle> grep 'set prompt' .cshrc set prompt = "$user@`uname -n`:$cwd> " We wish to have in production the same prompt, but red. Howto do that? I tried a lot a internet manuals, but it doesn't work. (1 Reply)
Discussion started by: slashdotweenie
1 Replies

8. Shell Programming and Scripting

Equivalent of set -o vi in csh

Hi, I am working with two shells on two different users. one is on ksh and one is on csh. In ksh I use set -o vi and I am able to see my history commands by typing esc,- keys. I want the same feature in csh as well how can I do that. Regards, Venkat (3 Replies)
Discussion started by: svenkatareddy
3 Replies

9. Shell Programming and Scripting

In a csh script, can I set a variable to the result of an SQLPLUS select query?

Can someone tell me why I'm getting error when I try to run this? #!/bin/csh -f source ~/.cshrc # set SQLPLUS = ${ORACLE_HOME}/bin/sqlplus # set count=`$SQLPLUS -s ${DB_LOGIN} << END select count(1) from put_groups where group_name='PC' and description='EOD_EVENT' and serial_number=1;... (7 Replies)
Discussion started by: gregrobinsonhd
7 Replies

10. Shell Programming and Scripting

alternate to set -x in csh scripts

hi all i want to debug a csh script and i give set -x for that but i get an error. is there any command similar to set -x for csh scripts? (3 Replies)
Discussion started by: sais
3 Replies
Login or Register to Ask a Question