Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > IPC::Run and hanging pipes

Reply
Thread Tools

IPC::Run and hanging pipes

 
 
Brian Hann
Guest
Posts: n/a
 
      12-08-2003
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.
 
Reply With Quote
 
 
 
 
Brian Hann
Guest
Posts: n/a
 
      12-11-2003
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?

http://www.velocityreviews.com/forums/(E-Mail Removed) (Brian Hann) wrote in message news:<(E-Mail Removed). 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.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
linux, named pipes (mkfifo) and a hanging application avishaih@mangodsp.com C Programming 17 01-13-2009 12:40 AM
os.popen and broken pipes Philipp Pagel Python 5 02-09-2007 08:47 PM
Java and UNIX pipes potato Java 3 07-22-2005 07:13 PM
using python on the command line with 'here-documents' and pipes calmar Python 6 11-15-2004 08:30 AM
sockets and pipes and bad results Marilyn Davis Python 0 09-25-2004 01:01 AM



Advertisments