From: Benjamin <mai...@sa...> - 2003-11-14 23:51:21
|
Hi all, I'm trying to play with Perl-Expect and I'm not having much success getting it to do a simple task. Here is the code: use Expect; $Expect::Exp_Internal = 1; my $exp = Expect->spawn("/bin/sh") or die "Cannot spawn /bin/bash: $!\n"; #print "got here\n"; $exp->expect(10, "sh"); $exp->send("ls \n"); With it, I'm trying to spawn sh and then do an ls (I know I can do ls directly, but I'm trying it this way for this example), but when I do this, I get the following output: Spawned '/bin/sh' spawn id(3) Pid: 5442 Tty: /dev/pts/2 Expect::spawn('Expect','/bin/sh') called at test.pl line 5 Starting EXPECT pattern matching... Expect::expect('Expect=GLOB(0x806479c)',10,'sh') called at test.pl line 8 spawn id(3): list of patterns: #1: -ex `sh' spawn id(3): Does `' match: pattern #1: -ex `sh'? No. Waiting for new data (10 seconds)... sh-2.05b$ spawn id(3): Does `sh-2.05b$ ' match: pattern #1: -ex `sh'? YES!! Before match string: `' Match string: `sh' After match string: `-2.05b$ ' Matchlist: () Returning from expect successfully. Sending 'ls \n' to spawn id(3) Expect::print('Expect=GLOB(0x806479c)','ls \x{a}') called at test.pl line 9 [userid@machineid userid]$ Without getting a list of the files. Any help is appreciated. I am using RedHat 9.0 with the latest expect modules from CPAN.org. Thanks, Ben |