Hi Roland,
On Tue, Oct 30, 2001 at 04:13:20PM +0100, Roland Giersig wrote:
> > I'm trying to write a Perl script that will record user input to a
> > program to allow that input to be "played" back and fed into the
> > program multiple
> > times. I'm sure I can do this with Expect, but I'm dropping my clue
> > somewhere along the way. I've tried a number of combinations like:
>
> There is a utility for Tcl/Expect called 'autoexpect' that does this,
> maybe you should just port that to perl. The problem with this task is
> that you have to determine what the program prompt looks like so you
> know when to send the next command. This often means that you have to
> put the script together by hand, so you also could just log the session
> to a logfile and do that by hand, pasting the appropriate strings into
> some send/expect template.
Right, autoexpect is exactly the kind of effect I was looking for. Once
I have the appropriate program input though I just feed it to the next
program invocation with < however, so I don't need to put together an
expect/send script with what the user types, just get a hold of it :).
> > Any pointers of where I'm going wrong would be greatly appreciated!
>
> Your code looks good in principle and should work. Have you tried
> setting $Expect::Exp_Internal = 1 to see what Expect is doing
> internally? $Expect::Debug could also be of help...
Thanks. That did help. The problem is that I listen to STDIN using
set_group(). Unfortunately the call to interact() does its own
set_group() call to get the program listening to STDIN. This clears
the listen group I had set up. I tried to bypass this by duplicating
some of the interact() code and calling interconnect() directly but
without much luck. I ended up just commenting out the clearing of
the listen group by set_group, which isn't the right solution, but
gets me going.
Have you considered an add_group/remove_group set of functions as
well as set_group? interact() could then be modified to use that
rather than clearing the listen groups with its own set_group calls.
regards, Greg
--
Greg Lewis Email : gl...@ey...
Eyes Beyond Phone : (801) 765 1887
Information Technology Web : http://www.eyesbeyond.com
|