Skip Menu |

This queue is for tickets about the Expect CPAN distribution.

Report information
The Basics
Id: 47268
Status: open
Priority: 0/
Queue: Expect

People
Owner: Nobody in particular
Requestors: tomilepp [...] sun3.oulu.fi
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Bug in expect 1.21
Date: Tue, 23 Jun 2009 13:01:34 +0300
To: bug-Expect [...] rt.cpan.org
From: Tomi Leppikangas <tomilepp [...] sun3.oulu.fi>
Hi, I moved on of our web application from apache 1.3 to 2.2 and run to problems with Expect.pm. I debugged problem and notised that STDIN from forked child is not working right. I have read similar reports about mod_perl. Usually there is problem with unclosed or untied STDIN/STDOUT. I managed to get it working by adding one more close to Expect.pm Here is diff for Expect 1.21: --- /root/.cpan/build/Expect-1.21/Expect.pm 2007-07-19 15:23:51.000000000 +0300 +++ /usr/lib/perl5/site_perl/5.8.8/Expect.pm 2009-06-23 12:57:59.000000000 +0300 @@ -157,6 +157,7 @@ die "Cannot sync with parent: $!" if not defined $errstatus; close FROM_PARENT; + POSIX::close(1); close(STDIN); open(STDIN,"<&". $slv->fileno()) or die "Couldn't reopen STDIN for reading, $!\n"; -- ## tomilepp cc oulu fi ## ## http://www.student.oulu.fi/~tomilepp/ ##
I know it has been a while ago, but I wonder, could you provide a test case for this scenario?
Subject: Re: [rt.cpan.org #47268] Bug in expect 1.21
Date: Thu, 14 Aug 2014 18:10:12 +0300
To: bug-Expect [...] rt.cpan.org
From: Tomi Leppikangas <tomilepp [...] sun3.oulu.fi>
Actually you have to close both STDIO and STDOUT to script to work Here is test case, without POSIX::close(1); POSIX::close(0); script prints error: /usr/bin/test.sh: line 3: read: read error: 0: Bad file descriptor perl script that works from command line, but not as cgi: ---------------------------------------------------- #!/usr/bin/perl -w use strict; use Expect; use CGI; my $q= new CGI; print $q->header; print "<html><body><p>test...\n"; my $exp = new Expect; $exp->raw_pty(1); $exp->spawn("/usr/bin/test.sh") ||die "spawn error: $!"; $exp->send("test\n"); $exp->soft_close(); if($exp->exitstatus() != 0) { print "Error\n</p><br>"; print $exp->before(); print "</body></html>"; exit; } print "</p><br>\n"; print "<p>OK</p>\n"; print "</body></html>"; ----------------------------------------------------- Dummy shellscript -------------------------------------------------- #!/bin/sh read line; echo $line > /tmp/test echo "OK" ----------------------------------------- -- ## tomilepp cc oulu fi ## ## http://www.student.oulu.fi/~tomilepp/ ##