From: Kilian A. F. <fo...@in...> - 2002-03-01 07:16:15
|
Austin Schutz writes: > On Thu, Feb 28, 2002 at 06:04:04PM +0100, Kilian A. Foth wrote: > > > > 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: > > > > our $pid = Expect->spawn("cat") or die "Couldn't spawn, $!"; > > I guess I don't understand what you expect to accomplish by this. > By spawning cat you are.. well.. catenating from STDIN to STDOUT. If you want > to interact with a program then why not spawn the program? > OK, example too minimal... The actual program is a part of speech tagger that reads words from its STDIN and writes tags to its STDOUT. I want to handle it through Expect so it will think it's talking to a terminal and not buffer its output. (It's closed source, so I can't hack it.) The real spawn is this: our $pid = Expect->spawn("/opt/pkg/tagger/bin/tagger", "-v0", "-z$args{z}", "$args{l}", "-") or die "Couldn't spawn, $!"; The tagger reads words such as: das and answers with tags such as: ARTDEF Since I don't know what it's going to answer, I have to expect everything: my @comm = $pid->expect(1,'-re',"^.*"); But then the first expect call picks up "das", and the next gets "ARTDEF". I thought $pid->expect() was supposed to read the child's output, not its input. Am I mistaken? |