in reply to Expect.pm Example(s)?
I have written exactly one (1) Perl program that used Expect. Unfortunately, after frenzied grepping of four different machines, I cannot lay my hands on it.
What I do remember is that by reading the perldoc I was able to figure out what I needed, except for one thing: I couldn't determine how you actually sent input to the process you were controlling through the Perl Expect object. It turns out that you treat the object as a filehandle, and print to it. I was looking for something like
$obj->send( $username )when in fact all you have to to is
print $obj $usernameThat's never clearly stated in the documentation (because it assumes you're familiar with Tcl/Tk, I guess). Apart from that it works pretty much as advertised. At the simplest, you do something like this:
# untested code, reciting from memory my $e = Expect->spawn( '/usr/local/bin/foo', '-f', '/tmp/bar' ); print $e "zug\n"; if( $e->expect(10, 'zwang')) { print "got what I expected\n"; } else { print "hmm..."; }
|
|---|