![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Help Required: Command to find IP address and command executed of a user | loggedout | Security | 2 | 08-06-2008 05:12 PM |
| how to? launch command with string of command line options | TinCanFury | Shell Programming and Scripting | 5 | 04-28-2008 03:06 PM |
| inconsistent ls command display at the command prompt & running as a cron job | rajranibl | Linux | 5 | 07-30-2007 05:26 AM |
| How to use more than one MPE command STREAM with Unix command in a single shell? | bosskr | HP-UX | 1 | 10-16-2006 01:16 PM |
| How to use more than one MPE command STREAM with Unix command in a single shell? | bosskr | Shell Programming and Scripting | 0 | 09-19-2006 06:44 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
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
|
|||
|
|||
|
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. |
|||
| Google The UNIX and Linux Forums |