From: Kilian A. F. <fo...@in...> - 2002-02-28 17:04:28
|
I'm trying to fool a proprietary program into thinking it is talking to a terminal when it is really talking to another program. Here is a minimal version to show my problem: #!/usr/bin/env perl use warnings; use strict; use Expect; our $pid = Expect->spawn("cat") or die "Couldn't spawn, $!"; $pid->log_stdout(0); sub read_output($ ) { my $s = shift; my @comm = $pid->expect(1,'-re',"$s"); (print "Error.", return 0) if $comm[1]; (print "No answer.", return 0) unless defined $comm[2]; (my $answer = $comm[2]) =~ s/\r/<NL>/; print "received `$answer'!\n"; return 1; } $pid->send("Hi there.\n"); while(read_output("^.+")){ # do nothing }; I expect the output: received `Hi there.<NL>'! But I get: received `Hi there.<NL>'! received `Hi there.<NL>'! Why is ->expect reading my own STDOUT? How can I make it stop? |