Re: [Boston.pm] backticks tee'd to stdout ?

2011-07-21 Thread Greg London
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

Re: [Boston.pm] backticks tee'd to stdout ?

2011-07-21 Thread Ronald J Kimball
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

Re: [Boston.pm] backticks tee'd to stdout ?

2011-07-21 Thread Greg London
@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

Re: [Boston.pm] backticks tee'd to stdout ?

2011-07-19 Thread Greg London
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.

Re: [Boston.pm] backticks tee'd to stdout ?

2011-07-19 Thread Greg London
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

[Boston.pm] backticks tee'd to stdout ?

2011-07-18 Thread Greg London
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

Re: [Boston.pm] backticks tee'd to stdout ?

2011-07-18 Thread Ben Tilly
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

Re: [Boston.pm] backticks tee'd to stdout ?

2011-07-18 Thread Greg London
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

Re: [Boston.pm] backticks tee'd to stdout ?

2011-07-18 Thread Uri Guttman
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

Re: [Boston.pm] backticks tee'd to stdout ?

2011-07-18 Thread Uri Guttman
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.

Re: [Boston.pm] backticks tee'd to stdout ?

2011-07-18 Thread belg4mit
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

Re: [Boston.pm] backticks tee'd to stdout ?

2011-07-18 Thread Brian Reichert
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,