Hi Dan,
2007/1/18, Dan Fish <[EMAIL PROTECTED]>:
I've got a perl wrapper that conditionally runs another perl program using
system()
Something like:
If( some_condition_applies){
system("myperlscript.pl");
}
myperlscript.pl will complete silently if everything runs right, but
because it reads some data files and interfaces to a mySQL database, there
are times when it may encounter unforeseen errors.
IF there is any output from myperlscript.pl, I'd like to capture it and send
it off in an email. The sending in an email part I can handle. and I think
I can probably redirect the output of myperlscript.pl to a file and read
that, but is there a better, more elegant way to capture any stdout/stderr
output WITHOUT having to redirect and read another file?
Why don't you encapsulate the myperlscript.pl code on a reusable
module, then just 'use' it? I'm supposing that both code was written
by you.
If you *really* needs that, you can use IPC::Open2 or IPC::Open3 (if
you also needs STDERR). From IPC::Open3 documentation (perldoc
IPC::Open3):
my($wtr, $rdr, $err);
$pid = open3($wtr, $rdr, $err,
'some cmd and args', 'optarg', ...);
HTH!
--
Igor Sutton Lopes <[EMAIL PROTECTED]>
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/