<?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: systask status / linux return code for multiple commands in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/systask-status-linux-return-code-for-multiple-commands/m-p/684343#M207369</link>
    <description>&lt;P&gt;&amp;amp;&amp;amp; is&amp;nbsp;&lt;U&gt;the&lt;/U&gt; UNIX way to do this; you'll see it in all kinds of setup/installation and other shell scripts.&lt;/P&gt;
&lt;P&gt;You can, of course, always catch the exit codes separately:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename os pipe 'gzip ~/notthere.txt; RC1=$?; touch ~/foo.txt; RC2=$?; echo "rc1=$RC1 rc2=$RC2"';

data retcode;
infile os end=done;
length retcodes $20;
input;
if done;
retcodes = _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 16 Sep 2020 18:49:18 GMT</pubDate>
    <dc:creator>Kurt_Bremser</dc:creator>
    <dc:date>2020-09-16T18:49:18Z</dc:date>
    <item>
      <title>systask status / linux return code for multiple commands</title>
      <link>https://communities.sas.com/t5/SAS-Programming/systask-status-linux-return-code-for-multiple-commands/m-p/684339#M207367</link>
      <description>&lt;P&gt;If I use systask to run two linux commands on one line, e.g.:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;systask command "gzip ~/notthere.txt; touch ~/foo.txt" status=mystatus shell wait;
%put &amp;gt;&amp;gt;&amp;amp;mystatus&amp;lt;&amp;lt; ;
&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The status returned is the status of the second command (touch in this case).&amp;nbsp; So even if the first command (gzip) fails, my status will be set to 0 because the second (touch) succeeded.&amp;nbsp; I recognize it's linux setting the exit code, not SAS.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Is there an easy way to grab the maximum status from all the commands that were submitted?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Okay, I googled, looks like using the &amp;amp;&amp;amp; operator could work for what I want.&amp;nbsp; If the first command fails, the second command won't be executed and I'll get the exit code from the first command:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;systask command 'gzip ~/notthere.txt &amp;amp;&amp;amp; touch ~/foo.txt' status=mystatus shell wait;
%put &amp;gt;&amp;gt;&amp;amp;mystatus&amp;lt;&amp;lt; ;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;Is there a better way?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Sep 2020 18:36:55 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/systask-status-linux-return-code-for-multiple-commands/m-p/684339#M207367</guid>
      <dc:creator>Quentin</dc:creator>
      <dc:date>2020-09-16T18:36:55Z</dc:date>
    </item>
    <item>
      <title>Re: systask status / linux return code for multiple commands</title>
      <link>https://communities.sas.com/t5/SAS-Programming/systask-status-linux-return-code-for-multiple-commands/m-p/684343#M207369</link>
      <description>&lt;P&gt;&amp;amp;&amp;amp; is&amp;nbsp;&lt;U&gt;the&lt;/U&gt; UNIX way to do this; you'll see it in all kinds of setup/installation and other shell scripts.&lt;/P&gt;
&lt;P&gt;You can, of course, always catch the exit codes separately:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename os pipe 'gzip ~/notthere.txt; RC1=$?; touch ~/foo.txt; RC2=$?; echo "rc1=$RC1 rc2=$RC2"';

data retcode;
infile os end=done;
length retcodes $20;
input;
if done;
retcodes = _infile_;
run;&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 16 Sep 2020 18:49:18 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/systask-status-linux-return-code-for-multiple-commands/m-p/684343#M207369</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2020-09-16T18:49:18Z</dc:date>
    </item>
  </channel>
</rss>

