Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Can you help? Thanks,#/usr/bin/perl # program to test open3() # module imports use strict; use warnings; use diagnostics; use IPC::Open3; use IO::Handle; use FileHandle (); # variable declarations my $pid; my $pid2; my @errors; my @output; my $pgp_command = "pgp --key-add temp_pgp_key.asc --with-private"; open (OUTPUT, ">&STDOUT") # output sent directly or die "Can't dup STDOUT to OUTPUT: $!\n"; open (ERROR, ">&STDERR") # error sent directly or die "Can't dup STDERR to ERROR: $!\n"; eval { $pid = open3(\*INPUT, \*OUTPUT, \*ERROR, $pgp_command) or die "could not run pgp command : $pgp_command : $!"; print INPUT "\n"; # wait for child to terminate with PID -1 but not in non-blocking m +ode? $pid2 = waitpid(-1,0); }; $@ && die "ERROR: $@\n"; # EVAL_ERROR print "process id : " . $pid . "\n"; print "exit value \$? : " . $? . "\n"; print "pid2 : " . $pid2 . "\n"; @output = <OUTPUT> or @errors = <ERROR> or die "Could not get response from PGP command : $pgp_command : +$!"; foreach (@output) { print "output " . $_ . "\n"}; foreach (@errors) { print "error " . $_ . "\n"}; close INPUT; close OUTPUT; close ERROR;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Open3 with STDIN STDOUT and STDERR
by BrowserUk (Patriarch) on Sep 12, 2002 at 10:26 UTC | |
by Anonymous Monk on Sep 12, 2002 at 10:42 UTC | |
|
Re: Open3 with STDIN STDOUT and STDERR
by fglock (Vicar) on Sep 12, 2002 at 13:28 UTC | |
by Anonymous Monk on Sep 12, 2002 at 13:37 UTC | |
|
Re: Open3 with STDIN STDOUT and STDERR
by greenFox (Vicar) on Sep 13, 2002 at 02:39 UTC |