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