Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UNIX shell scripting for SAS HELP!!! 1

Status
Not open for further replies.

sarav1981

Programmer
Jul 14, 2005
29
0
0
US
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:

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
 
Not really my forte, however, there should be a Unix Scripting forum here somewhere that would be able to give more help.

With the e-mail side though, you can actually do this from SAS, which would give you greater flexibility as you can set macro variables etc in the SAS program to put various messages in the e-mail body.
This code is for version 9. Previous versions require a set up statement to point ot the e-mail process.
Code:
filename doemail1 email to="Customer@company.com.au"
                       subject="Daily Reports - &REP_DATE"
                       cc="ChrisW75@company.com.au"
                       attach=("&outdir./daily_rep_vendor.xls"
                               "&outdir./daily_rep_account.xls");

...
...

data _null_ ;
   file doemail1;
   put "Dear Recipient," ;
   put " " ;
   put "AUTOMATICALLY GENERATED E-MAIL. PLEASE DO NOT REPLY! " ;
   put "Please forward any queries to ChrisW75.";
   put ;
   put "This is the Report for the date &rep_date."  ;
   put "Run on &prtdate" ;
   put ;

run ;
 
Hi Chris,

Thanks for the post. Will try my luck with the UNIX grp.

Sarav
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top