in reply to Re: STDOUT STDERR and response code from external Linix command
in thread STDOUT STDERR and response code from external Linix command
my $ret=`sh -e '$cmd' 2>&1`;
Didn't you mean -c ?
for my $cmd ('date', 'dat', 'date -foo') { print "cmd: $cmd\n"; my $out = `sh -c '$cmd' 2>&1`; my $rc = $? >> 8; print "out: $out"; print "rc: $rc\n\n"; } __END__ cmd: date out: Wed Jan 4 22:40:20 CET 2012 rc: 0 cmd: dat out: sh: dat: not found rc: 127 cmd: date -foo out: date: `oo': No such file or directory rc: 1
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: STDOUT STDERR and response code from external Linix command
by gdanenb (Acolyte) on Jan 05, 2012 at 06:41 UTC | |
by Eliya (Vicar) on Jan 05, 2012 at 11:01 UTC |