469,903 Members | 1,612 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,903 developers. It's quick & easy.

IPC::Run and hanging pipes

I am attempting to write an application that uses the expect binary to
get info off a telnet session. At first this app was written in
mod_perl under perl 5.005_03 using Expect.pm but we're moving it to
5.6.1 to take advantage of custom security and authentication and
Expect no longer works (similar to the IPC::Open2(3) problems under
mod_perl).

I am in the process of making the code use IPC::Run to call the expect
binary and use pipes to read and write data multiple times during a
session but I am having a problem where the read pipe just hangs, no
output and it never ever comes out of it unless I add a timeout. This
is on Solaris 8. Here is the example code:

#!/usr/bin/perl -w

use IPC::Run qw( start pump finish timeout run );

local(*Reader, *Writer, *ERR);

my @expect = qw( expect - );

my $h = start
\@expect,
'<pipe', \*Writer,
'>pipe', \*Reader,
'2>pipe', \*ERR, $t = timeout( 10 )
or die "expect returned $?" ;

warn "Starting first write\n";

print Writer qq~
exp_internal 1;
set timout 30\;
spawn telnet system

sleep 2

puts "NEXT"
~;

while (<Reader>) { last if /NEXT/; warn "READ\n"; print; }

warn "1\n";

It never gets past the while loop and it never puts out the READ warn
or any data either. I have tried moving this to use readline() in
both scalar and list context with the same results. Is there ANY way
to figure out why this is happening or to get data come back? I had
luck with IPC::Open2 but obviously I can't use that anymore under
mod_perl.
Jul 19 '05 #1
1 7213
Well I ended up modifying it to use scalar refs and pump() and it
works now. Do pipes just NOT work in mod_perl anymore?

c0***@beatdownsquad.com (Brian Hann) wrote in message news:<35**************************@posting.google. com>...
I am attempting to write an application that uses the expect binary to
get info off a telnet session. At first this app was written in
mod_perl under perl 5.005_03 using Expect.pm but we're moving it to
5.6.1 to take advantage of custom security and authentication and
Expect no longer works (similar to the IPC::Open2(3) problems under
mod_perl).

I am in the process of making the code use IPC::Run to call the expect
binary and use pipes to read and write data multiple times during a
session but I am having a problem where the read pipe just hangs, no
output and it never ever comes out of it unless I add a timeout. This
is on Solaris 8. Here is the example code:

#!/usr/bin/perl -w

use IPC::Run qw( start pump finish timeout run );

local(*Reader, *Writer, *ERR);

my @expect = qw( expect - );

my $h = start
\@expect,
'<pipe', \*Writer,
'>pipe', \*Reader,
'2>pipe', \*ERR, $t = timeout( 10 )
or die "expect returned $?" ;

warn "Starting first write\n";

print Writer qq~
exp_internal 1;
set timout 30\;
spawn telnet system

sleep 2

puts "NEXT"
~;

while (<Reader>) { last if /NEXT/; warn "READ\n"; print; }

warn "1\n";

It never gets past the while loop and it never puts out the READ warn
or any data either. I have tried moving this to use readline() in
both scalar and list context with the same results. Is there ANY way
to figure out why this is happening or to get data come back? I had
luck with IPC::Open2 but obviously I can't use that anymore under
mod_perl.

Jul 19 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Swaroop C H | last post: by
2 posts views Thread by a_agaga | last post: by
2 posts views Thread by Oriane | last post: by
2 posts views Thread by fahad.usman | last post: by
7 posts views Thread by Alex Y Wang | last post: by
7 posts views Thread by adrin | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.