<?xml version="1.0" encoding="windows-1252"?>
<node id="546801" title="Re^2: best practices for checking system return values for piped commands?" created="2006-05-01 22:41:02" updated="2006-05-01 18:41:02">
<type id="11">
note</type>
<author id="336451">
eXile</author>
<data>
<field name="doctext">
I second the use of bash-es PIPESTATUS, I've used it in code like this:
&lt;pre&gt;
my %cmds = ( 'bash' =&gt; '/usr/local/bin/bash',
             'gzip' =&gt; '/usr/bin/gzip',
             'lzop' =&gt; '/usr/bin/lzop',
             'wc'   =&gt; '/usr/bin/wc' );


my @zip_results = `$cmds{'bash'} -c '$cmds{$compress} -dc $file | $cmds{'wc'} -c ; echo \${PIPESTATUS[\@]}'`;
&lt;/pre&gt;
The last line of @zip_results has the status of both the 'compress' command and the 'wc' command.</field>
<field name="root_node">
546749</field>
<field name="parent_node">
546798</field>
</data>
</node>
