<?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 Handling STDERR output from PIPE utility in SAS Programming</title>
    <link>https://communities.sas.com/t5/SAS-Programming/Handling-STDERR-output-from-PIPE-utility/m-p/567139#M159452</link>
    <description>&lt;P&gt;One of our stored processes is using unnamed PIPE to run an exe file to parse addresses. Whenever it fails it logs a stderr output similar to the one below in the log and the process continues. We can not find out it failed until we look at the output or the log.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can we get our process to abort as soon as it finds stderr output from PIPE command ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;filename adv pipe "&amp;amp;cmd &amp;amp;inputFile. &amp;amp;location";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Stderr output:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Unhandled Exception: System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: Error 96: ERR_STAN_DLL_CALL_EXCEPTION. iPaf32.dll:FixLastLine&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 19 Jun 2019 05:31:51 GMT</pubDate>
    <dc:creator>Balli</dc:creator>
    <dc:date>2019-06-19T05:31:51Z</dc:date>
    <item>
      <title>Handling STDERR output from PIPE utility</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Handling-STDERR-output-from-PIPE-utility/m-p/567139#M159452</link>
      <description>&lt;P&gt;One of our stored processes is using unnamed PIPE to run an exe file to parse addresses. Whenever it fails it logs a stderr output similar to the one below in the log and the process continues. We can not find out it failed until we look at the output or the log.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How can we get our process to abort as soon as it finds stderr output from PIPE command ?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;filename adv pipe "&amp;amp;cmd &amp;amp;inputFile. &amp;amp;location";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Stderr output:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Unhandled Exception: System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: Error 96: ERR_STAN_DLL_CALL_EXCEPTION. iPaf32.dll:FixLastLine&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 05:31:51 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Handling-STDERR-output-from-PIPE-utility/m-p/567139#M159452</guid>
      <dc:creator>Balli</dc:creator>
      <dc:date>2019-06-19T05:31:51Z</dc:date>
    </item>
    <item>
      <title>Re: Handling STDERR output from PIPE utility</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Handling-STDERR-output-from-PIPE-utility/m-p/567143#M159455</link>
      <description>&lt;P&gt;Add a short command:&lt;/P&gt;
&lt;PRE&gt;&lt;CODE class=" language-sas"&gt;filename adv pipe "&amp;amp;cmd &amp;amp;inputFile. &amp;amp;location; echo $?";&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;The last line in your input will now contain the return code from your command.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 05:39:14 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Handling-STDERR-output-from-PIPE-utility/m-p/567143#M159455</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-19T05:39:14Z</dc:date>
    </item>
    <item>
      <title>Re: Handling STDERR output from PIPE utility</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Handling-STDERR-output-from-PIPE-utility/m-p/567145#M159457</link>
      <description>&lt;P&gt;Here my input is a text file and the pipe&amp;nbsp;command creates an output file with same name as input but with different extension.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I did not get the return code anywhere after adding echo.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 06:01:07 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Handling-STDERR-output-from-PIPE-utility/m-p/567145#M159457</guid>
      <dc:creator>Balli</dc:creator>
      <dc:date>2019-06-19T06:01:07Z</dc:date>
    </item>
    <item>
      <title>Re: Handling STDERR output from PIPE utility</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Handling-STDERR-output-from-PIPE-utility/m-p/567151#M159458</link>
      <description>&lt;P&gt;Mind that my shell code is for UNIX. If you are running SAS on Windows (yucc), you will have to use Windows syntax, but the principle should be the same. What I think will also work in Windows is 2&amp;gt;&amp;amp;1 (redirection of stderr to stdout).&lt;/P&gt;</description>
      <pubDate>Wed, 19 Jun 2019 07:01:04 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Handling-STDERR-output-from-PIPE-utility/m-p/567151#M159458</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-19T07:01:04Z</dc:date>
    </item>
    <item>
      <title>Re: Handling STDERR output from PIPE utility</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Handling-STDERR-output-from-PIPE-utility/m-p/567476#M159578</link>
      <description>"The last line in your input will now contain the return code from your command."&lt;BR /&gt;&lt;BR /&gt;Does that mean I need to look for the return code in my input text file ?</description>
      <pubDate>Wed, 19 Jun 2019 23:06:22 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Handling-STDERR-output-from-PIPE-utility/m-p/567476#M159578</guid>
      <dc:creator>Balli</dc:creator>
      <dc:date>2019-06-19T23:06:22Z</dc:date>
    </item>
    <item>
      <title>Re: Handling STDERR output from PIPE utility</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Handling-STDERR-output-from-PIPE-utility/m-p/567480#M159581</link>
      <description>&lt;P&gt;When used in an infile statement, the file reference created from filename pipe sends all output from the external command(s) to the input statement(s) in the data step. Since the final command displays the return code from the immediately preceding command, this will be the last "line" of your input.&lt;/P&gt;
&lt;P&gt;Still keep in mind that&lt;/P&gt;
&lt;PRE&gt;echo $?&lt;/PRE&gt;
&lt;P&gt;is UNIX syntax. Windows should work with&lt;/P&gt;
&lt;PRE&gt;echo %errorlevel%&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Jun 2019 23:30:52 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Handling-STDERR-output-from-PIPE-utility/m-p/567480#M159581</guid>
      <dc:creator>Kurt_Bremser</dc:creator>
      <dc:date>2019-06-19T23:30:52Z</dc:date>
    </item>
    <item>
      <title>Re: Handling STDERR output from PIPE utility</title>
      <link>https://communities.sas.com/t5/SAS-Programming/Handling-STDERR-output-from-PIPE-utility/m-p/568255#M159912</link>
      <description>&lt;P&gt;Thanks Kurt, this works using redirection of stderr to stdout and conditional processing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;filename adv pipe "&amp;amp;cmd &amp;amp;inputFile. &amp;amp;location &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;2&amp;gt;&amp;amp;1&lt;/STRONG&gt;&lt;/FONT&gt;";&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;data _null_;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; infile adv truncover;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; input;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; if index(lowcase(_infile_),'exception:') then do;&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; error ' Process Failed with an Exception';&lt;/STRONG&gt;&lt;BR /&gt;&lt;STRONG&gt;&amp;nbsp; &amp;nbsp; abort;&lt;/STRONG&gt;&lt;BR /&gt;&amp;nbsp; &amp;nbsp; end;&lt;/P&gt;&lt;P&gt;run;&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2019 00:30:20 GMT</pubDate>
      <guid>https://communities.sas.com/t5/SAS-Programming/Handling-STDERR-output-from-PIPE-utility/m-p/568255#M159912</guid>
      <dc:creator>Balli</dc:creator>
      <dc:date>2019-06-24T00:30:20Z</dc:date>
    </item>
  </channel>
</rss>

