Script to run sas job on autosys - Unix environment

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 10
Accepted Solution

Script to run sas job on autosys - Unix environment

Hello All,

 

What is the script to run a sas job on autosys in Unix environement. For windows we use .ps (powershell scripts) or .cmd (command line scripts). Can someone provide a template of the script?

 

Thanks,

Aj


Accepted Solutions
Solution
‎01-05-2017 12:58 PM
Respected Advisor
Posts: 3,901

Re: Script to run sas job on autosys - Unix environment

In the root folder of your SAS Server context - i.e..../Lev/SASApp - you'll find a script sas.sh

 

Use this script in autosys and then just pass in the parameters you need. You can test the correctness of the command line by executing it out of a command prompt (i.e. via Putty).

 

.../sas.sh -sysin <your SAS program> -log <same name as SAS program, add a timestamp to the name> .....

 

Using sas.sh has the advantage that all your .cfg adn autoexec's will get executed for the server context and though your batch jobs will get the same environment than what you've used during development via SAS EG or the like.

 

View solution in original post


All Replies
Super User
Posts: 6,964

Re: Script to run sas job on autosys - Unix environment

Could you post the template for the .cmd Windows batch file?

From this, one could deduce the requirements for a UNIX shell script.

 

It is also most important to know how autosys passes control parameters to jobs.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Occasional Contributor
Posts: 10

Re: Script to run sas job on autosys - Unix environment

Below is the script for .cmd Windows batch file to run on autosys.

 

 "C:\sas94\sashome\SASFoundation\9.4\sas.exe"  -config "C:\sas94\sashome\SASFoundation\9.4\nls\en\SASV9.CFG" -sysin "G:\ANALYTICS\SAS_CODE\Program\Program.sas" -LOG "G:\ANALYTICS\SAS_LOGS\Program\Program.log" -PRINT "G:\ANALYTICS\Reports\Program\Program.lst" -xcmd -noxwait -xsync -nosplash -icon -rsasuser

 

Do we have a similar template for Unix?

Solution
‎01-05-2017 12:58 PM
Respected Advisor
Posts: 3,901

Re: Script to run sas job on autosys - Unix environment

In the root folder of your SAS Server context - i.e..../Lev/SASApp - you'll find a script sas.sh

 

Use this script in autosys and then just pass in the parameters you need. You can test the correctness of the command line by executing it out of a command prompt (i.e. via Putty).

 

.../sas.sh -sysin <your SAS program> -log <same name as SAS program, add a timestamp to the name> .....

 

Using sas.sh has the advantage that all your .cfg adn autoexec's will get executed for the server context and though your batch jobs will get the same environment than what you've used during development via SAS EG or the like.

 

Occasional Contributor
Posts: 10

Re: Script to run sas job on autosys - Unix environment

Few questions running in my mind

1.Do I need to modify any lines in sas.sh ?

2.What command line should I use in the autosys. For example if I have a program.sas, I would create a command script at a location and give that path in the command on autosys. It may look like this \\servername\filepath\program.cmd or \\servername\filepath\program.ps1.

 

Please clarify!

Respected Advisor
Posts: 3,901

Re: Script to run sas job on autosys - Unix environment

[ Edited ]

Do I need to modify any lines in sas.sh ?

I wouldn't change sas.sh at all but you can always create and use a copy of the file and then add whatever modifications you like. The one thing I'm normally adding is a cd command pointing to the log directory so that any unspecified output goes there.

 

2.What command line should I use in the autosys.

You can use pretty much the same than what you've posted for Windows - just with different paths. As for the command posted for Windows: I would have used the sas.bat file there as well instead of the sas.exe (same reason: gives you the server context specific environment under which you've likely developed and unit tested your code).

 

@LinusH wrote: If you are using data integration the deployed job contains the full command line.

 

I've used such a command line from my Windows environment and below how this looks like (with some amendments):

/<root path>/SAS/Config/Lev1/SASApp/BatchServer/sasbatch.sh 
-sysin /<root path>/SAS/Config/Lev1/SASApp/SASEnvironment/SASCode/Jobs/my_prog.sas
-log /<root path>/SAS/Config/Lev1/SASApp/BatchServer/Logs/my_prog_#Y.#m.#d_#H.#M.#s.log  
-logparm "rollover=session"  
-batch 
-noterminal 
-print /<root path>/SAS/Config/Lev1/SASApp/BatchServer/Logs/my_prog.lst

 

You can see that it uses /BatchServer/sasbatch.sh. You can use this one as well if a batch server exists in your environment and there if you need to add any amendments to the script then add them to sasbatch_usermods.sh (it's already all there prepared and waiting for you - too easy).

 

Other possible amendments:

You could write a wrapper script which then includes sasbatch.sh or add changes directly to the sasbatch_usermods.shfile. You could for example add some parameter processing like: Instead of having to pass in fully qualified paths to -sysin, -log and -print add these paths as part of your script. You could for example on the outermost level only require to pass in the SAS program name without a path and then you add all the rest within your custom wrapper script (or within sasbatch_usermods.sh). This would make the command line you have to pass to Autosys much shorter.

Same is true for any additional parameters like -noterminal which you always want set for batch processing. 

Occasional Contributor
Posts: 10

Re: Script to run sas job on autosys - Unix environment

Thanks for a great and best explanation. This completely helped me fix my script.

Super User
Posts: 5,260

Re: Script to run sas job on autosys - Unix environment

If you are using data integration the deployed job contains the full command line.
Data never sleeps
☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 7 replies
  • 634 views
  • 4 likes
  • 4 in conversation