<?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 Re: How to redirect a log file when using a shell script in SAS Enterprise Guide</title>
    <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-redirect-a-log-file-when-using-a-shell-script/m-p/877306#M43013</link>
    <description>&lt;P&gt;I suggest that you use the&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/hostunx/n1csawccqbra9wn1c7tbyrkqv2t0.htm" target="_self"&gt; -LOG option on the sas command&lt;/A&gt; instead of the &amp;gt;&amp;gt; redirect in the shell script.&lt;/P&gt;</description>
    <pubDate>Wed, 24 May 2023 16:14:51 GMT</pubDate>
    <dc:creator>ChrisHemedinger</dc:creator>
    <dc:date>2023-05-24T16:14:51Z</dc:date>
    <item>
      <title>How to redirect a log file when using a shell script</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-redirect-a-log-file-when-using-a-shell-script/m-p/877301#M43012</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am using the following shell script to trigger a sas program and I wish to redirect to log file.&amp;nbsp; It does seems to work because I am getting two files.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;/.../dapuipa.genjcl.log&lt;BR /&gt;/.../dapuipa.genjcl.2023-05-24.log (this one is empty)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would like to have just one file, i.e.&amp;nbsp;/.../dapuipa.genjcl.2023-05-24.log with information in it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What's about this file:&amp;nbsp;/.../dapuipa.genjcl.lst&amp;nbsp; . Should I redirect and rename this file to avoid an error 11.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please provide corrected script&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;orderdate=$1
ordertime=$2
surveyname=$3
env=$4

#-----------------------------------------------------------
# Cron entries do not execute login scripts.
# Let's run it in the context of our current process
#-----------------------------------------------------------

. /etc/profile

#---------------------------------------------------------------------------------
# Read the parameters and excute the SAS function dapuipa.genjcl.sas
#---------------------------------------------------------------------------------

echo "$orderdate|$ordertime|$name|$env"

sas  -sysparm  "$orderdate|$ordertime|$name|$env" /.../dapuipa.genjcl.sas &amp;gt;&amp;gt; "dapuipa.genjcl.$(date +'%Y-%m-%d').log"

#--------------------
# Exit procedure
#--------------------

exit $?

&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 16:04:48 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-redirect-a-log-file-when-using-a-shell-script/m-p/877301#M43012</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2023-05-24T16:04:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to redirect a log file when using a shell script</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-redirect-a-log-file-when-using-a-shell-script/m-p/877306#M43013</link>
      <description>&lt;P&gt;I suggest that you use the&lt;A href="https://go.documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/hostunx/n1csawccqbra9wn1c7tbyrkqv2t0.htm" target="_self"&gt; -LOG option on the sas command&lt;/A&gt; instead of the &amp;gt;&amp;gt; redirect in the shell script.&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 16:14:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-redirect-a-log-file-when-using-a-shell-script/m-p/877306#M43013</guid>
      <dc:creator>ChrisHemedinger</dc:creator>
      <dc:date>2023-05-24T16:14:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to redirect a log file when using a shell script</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-redirect-a-log-file-when-using-a-shell-script/m-p/877314#M43014</link>
      <description>&lt;P&gt;Use the -log option to specify the name of the LOG file.&amp;nbsp; Use the -print option to specify the name of the print file (what SAS now calls the "listing" destination).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You might want to use the Unix output re-direction to a third error file to capture any error messages caused by disk outages or whatever.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So perhaps something like this:&lt;/P&gt;
&lt;PRE&gt;cd /.../logfolder/ 

echo "$orderdate|$ordertime|$name|$env" &amp;gt;&amp;gt; dapuipa.genjcl.$(date +'%Y-%m-%d').cronlog

sas  -sysparm  "$orderdate|$ordertime|$name|$env" \
     -log dapuipa.genjcl.$(date +'%Y-%m-%d').log \
     -print dapuipa.genjcl.$(date +'%Y-%m-%d').log \
     /.../dapuipa.genjcl.sas \
     2&amp;gt;&amp;amp;1 &amp;gt;&amp;gt; dapuipa.genjcl.$(date +'%Y-%m-%d').cronlog
&lt;/PRE&gt;
&lt;P&gt;You should also look at the -set option as it will give you much more flexibility to pass in multiple parameters than the single string the old -sysparm option supports.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;sas -set orderdate "$orderdate" -set ordertime "$ordertime" -set name "$name" -set env "$env" ....&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Then in the SAS code you can use SYMGET() or %SYMGET() to retrieve the individual environment variable values instead of trying to parse it out of SYSPARM.&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;%let orderdate=%symget(orderdate);
%let ordertime=%symget(ordertime);
%let name=%symget(name);
%let env=%symget(env);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 24 May 2023 16:40:05 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-redirect-a-log-file-when-using-a-shell-script/m-p/877314#M43014</guid>
      <dc:creator>Tom</dc:creator>
      <dc:date>2023-05-24T16:40:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to redirect a log file when using a shell script</title>
      <link>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-redirect-a-log-file-when-using-a-shell-script/m-p/877335#M43015</link>
      <description>does the print option should end with .lst&lt;BR /&gt;&lt;BR /&gt;ex:&lt;BR /&gt;&lt;BR /&gt;-print dapuipa.genjcl.$(date +'%Y-%m-%d').lst \</description>
      <pubDate>Wed, 24 May 2023 17:58:12 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Enterprise-Guide/How-to-redirect-a-log-file-when-using-a-shell-script/m-p/877335#M43015</guid>
      <dc:creator>alepage</dc:creator>
      <dc:date>2023-05-24T17:58:12Z</dc:date>
    </item>
  </channel>
</rss>

