06-27-2017 10:02 AM
I'm trying to create a shell script to execute SAS in command line. The objetive is use it to run SAS programns in crontab. The shell script created use two parameters, $1 and $2. The first parameter ($1) is the complete path of SAS program to execute and the second one ($2) is the user's name of the responsible.
$ which sasprogram
$ more /usr/bin/sasprogram
nohup /<path>/BatchServer/sasbatch.sh -log /<path>/logs/$prog.#Y_#m_#d.log -batch -noterminal -logparm "rollover=session" -xcmd -autoexec /<path>/autoexec.sas -sysparm "$1|$2" &
I'm using the following command line to execute:
sasprogram /<path>/SAScode.sas UserName
After run, log file is empty as shown below:
$ cat /<path>/logs/SAScode.sas.2017_06_26.log
NOTE: Log file opened at Mon, 26 Jun 2017 16:11:58.754
And in nohup.out log the following message appears:
$ cat nohup.out
/<path>/sasbatch.sh: UserName: not found
Any ideia what is going on?
06-27-2017 10:38 AM
Inspect line 46 of sasbatch.sh to see why Username ends up being taken for a UNIX command.
What I see is that in your call to sasbatch.sh you do not supply the program path and name. You set the log and the autoexec, but there's no -sysin or equivalent. That is the reason for the empty log.
06-27-2017 10:59 AM
Looks like you have bug in the sasbatch.sh program that your program is calling. Most likely it is not properly transfering its input parameters onto the SAS executable. In particular it looks like quotes around the pipe character in the value of -sysparm option are not being honored and so UserName is being interpretted by the shell as the name of the program to pipe the output of the SAS job into. Is it passing the parameters using "$@" ?
You could try calling it with \| instead of | to protect the pipe character, but I think you probably need to fix that other script.