From: Benjamin <mai...@sa...> - 2003-11-17 22:26:54
|
Adding te $exp-expect at the end solved the issue. Now I just need to be able to capture the output. Thanks, Ben ---------- Original Message ----------- From: "Andrew & Laurie White" <and...@ve...> To: "Benjamin" <mai...@sa...> Sent: Sat, 15 Nov 2003 18:56:04 -0500 Subject: Re: [Expectperl-discuss] Perl Expect and sh > i don't have my unix machine nearby but a quick thought was to use \r > instead of \n to the ls command > > you may also want to have another $exp->expect(10, "sh"); > after the ls send . > > ----- Original Message ----- > From: "Benjamin" <mai...@sa...> > To: <exp...@li...> > Sent: Friday, November 14, 2003 6:51 PM > Subject: [Expectperl-discuss] Perl Expect and sh > > > 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 > > > > > > ------------------------------------------------------- > > This SF. Net email is sponsored by: GoToMyPC > > GoToMyPC is the fast, easy and secure way to access your computer from > > any Web browser or wireless device. Click here to Try it Free! > > https://www.gotomypc.com/tr/OSDN/AW/Q4_2003/t/g22lp?Target=mm/g22lp.tmpl > > _______________________________________________ > > Expectperl-discuss mailing list > > Exp...@li... > > https://lists.sourceforge.net/lists/listinfo/expectperl-discuss ------- End of Original Message ------- |