Zbigniew Fiedorowicz <> wrote in message news:<bvto7c$9k$>...
> How can I catch error messages from external programs forked
> from a Perl cgi process? I can of course read from the web
> server error log, but I am worried that I might be getting
> the wrong error messages from some other web server process
> which is running concurrently.
Do you mean fork()ed or do you mean a truely external program (e.g.
using system, qx{} or fork()/exec)?
Let's use qx{} (aka ``) as a simple example:
method a:
$result_plus_err = qx{/usr/bin/do_stuff 2>&1};
method b:
use IPC::Open3 qw(open3);
use IO::Select;
open3(\*WTRFH, \*RDRFH, \*ERRFH, "/usr/bin/do_stuff");
close WTRFH;
my $r = IO::Select->new(\*RDRFH,\*ERRFH);
and from there you can call the "can_read" method on $r and continue
along your happy way.
|