|
From: Blackstone, J. D. <jda...@ci...> - 2002-01-16 13:28:03
|
Try setting the $| variable. Mixing output of different programs in your
STDOUT stream can cause them to come out in different orders because of
buffering.
Alternatively, try storing the output of ls yourself in a variable and
outputting it in the proper sequence.
jdb
-----Original Message-----
From: Todd Rosenberry [mailto:ros...@xi...]
Sent: Tuesday, January 15, 2002 6:33 PM
To: exp...@li...
Subject: [Expectperl-discuss] Expect and CGI
I'm am trying to use Expect in a CGI program and am having strange
results. Here is a very much stripped down version of my code. It is just
for example purposes. I would expect to get a page with a "Go" button and
when I press it I would see
staring spawn (ls)
spawn done
Listing: <listing>
<GO>
instead I see
staring spawn (ls)
Content-type: text/html staring spawn (ls)
spawn done
Listing: <listing>
<GO>
Its like the whole program is starting over the first time it sees the
spawn line but the command is only being executed once. Any idea what's
going on?
#!/var/yp/bin/perl
use CGI;
use Expect;
$Expect::Log_Stdout=0;
$query = new CGI;
$formAction=$query->url();
$action=$query->param('action');
print "Content-type: text/html\n\n";
if ($action eq "Go") {
$cmd="ls";
print "spawn starting ($cmd)<BR>\n";
$run = Expect->spawn("$cmd");
print "spawn done<BR>\n";
$run->expect(10,'-re','.*');
print "Listing: " . $run->match(). "<BR>\n";
};
print "<BR><FORM action=$formAction METHOD=post>\n";
print "<INPUT TYPE=submit name=action value=Go><BR><BR>\n";
- Todd
|