Hi,
some alternative approaches would be:
my $res = `$cmd`; # note that it's not "'" but "`"
# $res only stdout, this will puke out stderr
or
my $res = `$cmd 2>&1`; # redirect stderr to stdout
# $res is now both stderr and stdout
or
my $res = `$cmd 2>/dev/null`; # throw away stderr
# $res
Hi,
You can always write STDERR and STDOUT to a temp file then read the contents
of this file back in to your script.
eg
system (some_command 1>.stdout 2>.stder);
STDOUT is written to .stdout
STDERR is written to .stderr
Theres is probably a better way than this but I find this the easiest.
> "Jeff 'japhy' Pinyan" <[EMAIL PROTECTED]> said:
> Of course, all of these should have error-checking:
>
> $x = `...` or die "can't run ...: $!";
>
> open OUTPUT, "... |" or die "can't run ...: $!";
Don't forget to check the close for errors. If the pipe fails for some reason
close retur
On Sep 27, Matthew Blacklow said:
>What I need to do is capture the screen output of this process into a string
>variable so that it can latter be manipulaterd. ie. capture the STDOUT.
Several options:
# qx() and `` are the same
$output = `prog arg1 arg2`;
$output = qx(prog arg1 arg2);