LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (March 2006, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 16 Mar 2006 14:05:27 -0800
Reply-To:     RolandRB <rolandberry@HOTMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         RolandRB <rolandberry@HOTMAIL.COM>
Organization: http://groups.google.com
Subject:      Re: UNIX Shell script for SAS HELP!!!
Comments: To: sas-l@uga.edu
In-Reply-To:  <1142542134.016988.15980@p10g2000cwp.googlegroups.com>
Content-Type: text/plain; charset="iso-8859-1"

Sarav wrote: > 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,.

You will not be allowed to kill other people's processes unless you are a super user, I think. You might find it difficult, in any case, to find out what these other processes are running.

> 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 > exit 1 > fi

What you have coded above means that if it finds the sas program in your directory it will tell you so and then exit the script with a 1 return code. This is not what you want.

> # 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


Back to: Top of message | Previous page | Main SAS-L page