linuxfan has asked for the wisdom of the Perl Monks concerning the following question:
Now, I also want to be able to read the data that the binary writes to STDOUT as I want to verify that it is printing the right questions to STDOUT. I have looked at the Expect module and think it can help me do what I want. However, I am looking for a simpler method (if possible). Can you holy monks show me the way?sub ExecCmd { my ($cmd,$pipe) = @_; my @result; if(defined $pipe) { LogInfo("Executing $cmd"); open PIPE,"| $cmd" or die "Cannot fork command: $!"; local $SIG{PIPE} = sub { die "Failed to execute $cmd" }; print PIPE "0\n"; close PIPE; unshift @result,"PASS"; return \@result; } }
Thanks a lot!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Executing command from perl script with input/output
by bart (Canon) on Aug 08, 2005 at 17:30 UTC | |
by ikegami (Patriarch) on Aug 08, 2005 at 17:50 UTC | |
|
Re: Executing command from perl script with input/output
by zentara (Cardinal) on Aug 08, 2005 at 18:03 UTC | |
by linuxfan (Beadle) on Aug 08, 2005 at 18:21 UTC | |
by zentara (Cardinal) on Aug 09, 2005 at 11:25 UTC | |
by linuxfan (Beadle) on Aug 09, 2005 at 19:48 UTC | |
by zentara (Cardinal) on Aug 10, 2005 at 11:30 UTC | |
|