|Date: ||Thu, 16 Mar 2006 12:48:54 -0800|
|Reply-To: ||Sarav <sarav.sas@GMAIL.COM>|
|Sender: ||"SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>|
|From: ||Sarav <sarav.sas@GMAIL.COM>|
|Subject: ||UNIX Shell script for SAS HELP!!!|
|Content-Type: ||text/plain; charset="iso-8859-1"|
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:
# 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
# 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!" firstname.lastname@example.org
uuencode test.log | mailx -s "Test Code Log File" email@example.com