pid has asked for the wisdom of the Perl Monks concerning the following question:
Greetings all my fellow monks,
After running this line:
where cmd is a little program written in C, which mainly does some printf stuff.run \@cmd, \$in, \$out, \$err, timeout( 3, exception => 'timeout' );
#!/usr/bin/perl -w use strict; use warnings; use CGI qw/:standard/; use CGI::Carp qw/fatalsToBrowser warningsToBrowser/; use IPC::Run qw/run timeout/; if (param('in')) { $in = param('in'); print p("Input: $in\n"); } else { undef $in; } my @cmd = ( "/data2/tmp/a.exc" ); eval { local $| = 1; run \@cmd, \$in, \$out, \$err, timeout( 3, exception => 'timeo +ut' ); }; print "Timed out...\n\n" if $@ =~ /timeout/; print "ERROR: $err\n\n" if $err; chomp($out) && print "Output: $out\n" if $out; print "Expected output: ", param('out') if param('out');
Update 2:
Sorry, I think it's all my fault:
chomp($out) && print "Output: $out\n" if $out;
This is where the problem lies...after removing chomp($out) &&, things back to normal again. Now I don't know what to say or explain....
A letter to NodeReaper:
The connection here was kinda weird on my attempt to send replies to this node.
I could reach the preview page at a good speed, but when I did the real submission, things became very slow, and finally I got a ``content-length: 0'' on my Opera window...
I think that's why you got many empty nodes. It's okay now.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Get output after running IPC::Run
by Khen1950fx (Canon) on Nov 23, 2009 at 08:02 UTC | |
Re: Get output after running IPC::Run
by cdarke (Prior) on Nov 23, 2009 at 11:08 UTC | |
by pid (Monk) on Nov 23, 2009 at 11:45 UTC | |
by gmargo (Hermit) on Nov 23, 2009 at 19:39 UTC | |
by pid (Monk) on Nov 24, 2009 at 03:46 UTC | |
Re: Get output after running IPC::Run
by zentara (Cardinal) on Nov 23, 2009 at 13:09 UTC | |
Re: Get output after running IPC::Run
by ikegami (Patriarch) on Nov 23, 2009 at 18:23 UTC | |
by pid (Monk) on Nov 24, 2009 at 03:34 UTC | |
Re: Get output after running IPC::Run
by ikegami (Patriarch) on Nov 24, 2009 at 04:01 UTC | |
by pid (Monk) on Nov 24, 2009 at 07:07 UTC |