Ken <[EMAIL PROTECTED]> wrote:
> I have an external program (not in perl, and not written by me).
> I want to send a string to it, have it do it's thing, then return
> the output to my perl program. Then, depending on the results, I
> might need to run the external program again with a different string.
>
> I'm close with the following:
> open BL, "|-", "bl -d /usr/local/share/bl" #open program with parameters
> or die "cant open bl fork: $!";
> local $SIG{PIPE} = sub { die "bl pipe broke"};
> print BL "stuff\n\n"; #send this to the program bl
> close BL or die "bad close $!";
>
> This sends the output to the screen, STDOUT. So I think my next
> step is to use a socketpair so I can gather the ouput and use it.
> But I can't figure out how to set this up.
Switching to IPC::Open2 would be easier:
use IPC::Open2;
my $pid = open2 *BLR, *BLW, qw(bl -d /usr/local/share/bl)
or die "cant open bl fork: $!";
local $SIG{PIPE} = sub { die "bl pipe broke" };
print BLW "stuff\n\n";
my $reply = <BLR>;
# etc...
close BLW or die "close bl writer: $!";
close BLR or die "close bl reader $!";
waitpid $pid, 0;
--
Steve
perldoc -qa.j | perl -lpe '($_)=m("(.*)")'
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]