Hi all,
I am in the process of writing an UNIX shell script (korn and I use AIX) to run a SAS code on the admin account on an UNIX server.
I want the code to do these set of actions:
a. Look for the code to run in the specified directory.
b. If the code is not present in that directory, it should display a message saying so and exit the script.
c. If it does find the code, it should check for the similar named code being run by other users, if so it shud kill the other process and then send a message/email back saying that job id xxx was cancelled by job id yyy etc,.
d. when step (c) completes successfully, it should run the code.
e. Upon completion, it should send a message/email saying that the code completed its run with the attachment of the log in the email.
I think, I was able to get step (a) completely, step (b) partially, step (d) completely and step (e) partially. If the UNIX gurus here can help me finish up the entire script with my above mentioned tasks it would be great.
Below is what I have drafted as of now:
Thanks,
Sarav
I am in the process of writing an UNIX shell script (korn and I use AIX) to run a SAS code on the admin account on an UNIX server.
I want the code to do these set of actions:
a. Look for the code to run in the specified directory.
b. If the code is not present in that directory, it should display a message saying so and exit the script.
c. If it does find the code, it should check for the similar named code being run by other users, if so it shud kill the other process and then send a message/email back saying that job id xxx was cancelled by job id yyy etc,.
d. when step (c) completes successfully, it should run the code.
e. Upon completion, it should send a message/email saying that the code completed its run with the attachment of the log in the email.
I think, I was able to get step (a) completely, step (b) partially, step (d) completely and step (e) partially. If the UNIX gurus here can help me finish up the entire script with my above mentioned tasks it would be great.
Below is what I have drafted as of now:
Code:
# check on the existence of a sas program in the home directory
if [ -f $HOME/test.sas ] ; then
echo "SAS program for testing 'test.sas' exists in your
home directory." 1>&2
exit 1
fi
# Run the SAS code
sas -log "$HOME" -sysin "$HOME/test.sas"
# Run completion notification e-mail with LOG attachment to ADMIN
echo "Test SAS code completed!" | mailx -s "Run Completed!" xxx@sas.com
uuencode test.log | mailx -s "Test Code Log File" xxx@sas.com
Thanks,
Sarav