<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Execute SAS using command line in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Execute-SAS-using-command-line/m-p/370938#M88588</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Shell&lt;/P&gt;&lt;P&gt;--------&lt;/P&gt;&lt;P&gt;&lt;EM&gt;##&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$ which sasprogram&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;/usr/bin/sasprogram&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$ more /usr/bin/sasprogram&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;#!/bin/sh&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;umask 007&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;PATH=.:opt/bin:/bin:/usr/sbin:/usr/bin:/usr/ccs/bin:/GNU/bin/make:/usr/ucb:/sas/software/SASFoundation/9.2/bin&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;export PATH&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;progpath=`dirname "$1"`&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;prog=`basename "$1"`&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;cd $progpath&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;nohup /&amp;lt;path&amp;gt;/BatchServer/sasbatch.sh -log /&amp;lt;path&amp;gt;/logs/$prog.#Y_#m_#d.log -batch -noterminal -logparm "rollover=session" -xcmd -autoexec /&amp;lt;path&amp;gt;/autoexec.sas -sysparm "$1|$2" &amp;amp;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;##&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;----&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using the following command line to execute:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;sasprogram /&amp;lt;path&amp;gt;/SAScode.sas UserName&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After run, log file is empty as shown below:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;$ cat /&amp;lt;path&amp;gt;/logs/SAScode.sas.2017_06_26.log&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;NOTE: Log file opened at Mon, 26 Jun 2017 16:11:58.754&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And in nohup.out log the following message appears:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;$ cat nohup.out&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;/&amp;lt;path&amp;gt;/sasbatch.sh[46]: UserName:&amp;nbsp; not found&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideia what is going on?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 27 Jun 2017 14:02:01 GMT</pubDate>
    <dc:creator>MariaD</dc:creator>
    <dc:date>2017-06-27T14:02:01Z</dc:date>
    <item>
      <title>Execute SAS using command line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Execute-SAS-using-command-line/m-p/370938#M88588</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Shell&lt;/P&gt;&lt;P&gt;--------&lt;/P&gt;&lt;P&gt;&lt;EM&gt;##&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$ which sasprogram&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;/usr/bin/sasprogram&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$ more /usr/bin/sasprogram&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;#!/bin/sh&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;umask 007&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;PATH=.:opt/bin:/bin:/usr/sbin:/usr/bin:/usr/ccs/bin:/GNU/bin/make:/usr/ucb:/sas/software/SASFoundation/9.2/bin&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;export PATH&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;progpath=`dirname "$1"`&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;prog=`basename "$1"`&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;cd $progpath&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;nohup /&amp;lt;path&amp;gt;/BatchServer/sasbatch.sh -log /&amp;lt;path&amp;gt;/logs/$prog.#Y_#m_#d.log -batch -noterminal -logparm "rollover=session" -xcmd -autoexec /&amp;lt;path&amp;gt;/autoexec.sas -sysparm "$1|$2" &amp;amp;&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;$&lt;/EM&gt;&lt;BR /&gt;&lt;EM&gt;##&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;----&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm using the following command line to execute:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;sasprogram /&amp;lt;path&amp;gt;/SAScode.sas UserName&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;After run, log file is empty as shown below:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;$ cat /&amp;lt;path&amp;gt;/logs/SAScode.sas.2017_06_26.log&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;NOTE: Log file opened at Mon, 26 Jun 2017 16:11:58.754&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And in nohup.out log the following message appears:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;$ cat nohup.out&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;/&amp;lt;path&amp;gt;/sasbatch.sh[46]: UserName:&amp;nbsp; not found&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any ideia what is going on?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jun 2017 14:02:01 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Execute-SAS-using-command-line/m-p/370938#M88588</guid>
      <dc:creator>MariaD</dc:creator>
      <dc:date>2017-06-27T14:02:01Z</dc:date>
    </item>
    <item>
      <title>Re: Execute SAS using command line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Execute-SAS-using-command-line/m-p/370956#M88598</link>
      <description>&lt;P&gt;Inspect line 46 of sasbatch.sh to see why Username ends up being taken for a UNIX command.&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jun 2017 14:38:15 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Execute-SAS-using-command-line/m-p/370956#M88598</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2017-06-27T14:38:15Z</dc:date>
    </item>
    <item>
      <title>Re: Execute SAS using command line</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Execute-SAS-using-command-line/m-p/370963#M88603</link>
      <description>&lt;P&gt;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. &amp;nbsp;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. &amp;nbsp;Is it passing the parameters using&amp;nbsp;"$@" ?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could try calling it with \| instead of | to protect the pipe character, but I think you probably need to fix that other script.&lt;/P&gt;</description>
      <pubDate>Tue, 27 Jun 2017 14:59:16 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Execute-SAS-using-command-line/m-p/370963#M88603</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2017-06-27T14:59:16Z</dc:date>
    </item>
  </channel>
</rss>

