From: Vladimir K. <ma...@ma...> - 2007-03-21 11:04:54
|
Hello, I have same problem, Expect not working in custom environment, probably because of stdin, stdout redirections. I'm using mod_perl, and simple expect scenario works perfect in shell and not at all in mod_perl i'm trying to connect server side and do some data exchange. server: while :; do nc -l -p333 -c'echo READY; read RESP; echo READY2; sleep 10'; echo Exited; done (listening at 333 port, sending READY on connect and READY2 on first line receive) my script: use Expect; my $myhandle = new Expect; $myhandle->log_user(0); $myhandle->spawn("nc 192.168.1.11 333"); $myhandle->expect(10, [ timeout => sub { print STDERR "timeout\n" } ], [ eof => sub { print STDERR "eof\n" } ], [ qr/READY[\r\n]+/ => sub { print STDERR "READY\n" } ], ); $myhandle->send("TEST\n"); $myhandle->expect(10, [ timeout => sub { print STDERR "timeout\n" } ], [ eof => sub { print STDERR "eof\n" } ], [ qr/READY2[\r\n]+ => sub { print STDERR "READY2\n" } ], ); from shell it shows: READY READY2 from mod_perl it shows: READY timeout so it hanging just after first data sent to server :( Bryan Cox wrote: > > Brad and Austin, > > I've finally figured this thing out (sort of). Expect works fine in a > "normal" environment. > > We have a utility built in-house that we use to log the output of our > scripts. That utility does some forking, redirection of stdin & stdout, > and unbuffering before I make my Expect call. Between the two modules, > there's just one too many redirects or something. I'm not sure if I'll > ever get it sorted out to the point where I can make them work together, > but they work fine independently. > > I've appreciated your help, and hope I can return the favor some time. > > Bryan > > -- View this message in context: http://www.nabble.com/Expect.pm---sftp-tf3398274.html#a9591652 Sent from the Perl - Expectperl-Discuss mailing list archive at Nabble.com. |