Oh fer the luv of...
everything is doing what I want now,
*except* when a command has a nonzero exit code,
the script can't seem to see that.
Here's a little shell script called exit_one.csh
echo EXIT_ONE
exit 1
Here's the perl script (perl_pipe.pl) that runs it with an open pipe:
my
On Thu, Jul 21, 2011 at 01:44:48PM -0500, Greg London wrote:
If I open a pipe on a command that has a nonzero exit status,
where do I check that???
perldoc -f close
Ronald
___
Boston-pm mailing list
Boston-pm@mail.pm.org
@mail.pm.org
Sent: Thu, Jul 21, 2011 19:41:42 GMT+00:00
Subject: Re: [Boston.pm] backticks tee'd to stdout ?
On Thu, Jul 21, 2011 at 01:44:48PM -0500, Greg London wrote:
If I open a pipe on a command that has a nonzero exit status,
where do I check that???
close($HANDLE2);
after the read loop
Ah-ha.
I'm not entirely crazy, just extremely forgetful.
I knew I had done a script like this a couple years ago
and I knew it used backticks and I knew it had a timeout feature.
The part I forgot was it used Tk::ExecuteCommand to
manage the process. It also shows the output of the
simulation.
So, if I were to use pipes, with a timeout, would it look something like
this?
#!/usr/bin/perl
use warnings;
use strict;
$SIG{ALRM} = sub { die timeout\n };
alarm(7);
my $pid = open(my $HANDLE,
echo \A\; sleep 3;
.echo \B\; sleep 3;
.echo \C\; sleep 3;
.echo
I have a script that uses backticks to run commands, capture the output and
append it to a file. Someone requested that the script also output
immediately to the screen. we are having troubles with some commands
hanging, amd we want to know where the hang is. so if we could see the last
Sounds like you're suffering from buffering:
http://perl.plover.com/FAQs/Buffering.html
The only way to solve your problem is to convince the program that it
should not buffer its output. Sometimes you'll have a command switch
you can hit to force that (particularly if you wrote those
London em...@greglondon.com
Cc: Boston-pm@mail.pm.org
Sent: Mon, Jul 18, 2011 21:49:47 GMT+00:00
Subject: Re: [Boston.pm] backticks tee'd to stdout ?
GL == Greg London Greg writes:
GL Is there an easy way to tweak backticks so it still captures the
GL output but also tees the output to stdout
GL == Greg London Greg writes:
GL I have been assuming that the 'correct' behavior of perl is that
GL when perl calls die while it is running a command via bacticks
GL that perl kills whatever was run by the backtick command.
GL is that a correct assumption?
not that i know. perl
GL == Greg London em...@greglondon.com writes:
GL CRAP!
GL #!/usr/bin/perl
GL use warnings;
GL use strict;
GL $SIG{ALRM} = sub { die timeout\n };
that only exits the eval block. you need to kill the process. you can't
do that without the pid and backticks doesn't get you the pid.
Don't do that.
In general, you're going to run into a whole mess of problems with the kind
of thing you want to do, and your best is to control everything and avoid
the shell. Pipe opens, as Uri suggested, are the way to go, unless you need
bi-/tri-directional support in which case there are
On Mon, Jul 18, 2011 at 06:59:58PM -0400, belg4...@pthbb.org wrote:
Don't do that.
In general, you're going to run into a whole mess of problems with the kind
of thing you want to do, and your best is to control everything and avoid
the shell. Pipe opens, as Uri suggested, are the way to go,
12 matches
Mail list logo