in reply to Perl Expect Command output
First, try running it in debug mode
Expect the unexpected:).#!/usr/bin/perl use strict; use warnings; use Expect; $Expect::Debug = 1; my $timeout = 10; ...
Update: In case you're still stumped, I put help in a callback. Give this a try:
#!/usr/bin/perl -slw use strict; use Expect; use Data::Dumper::Concise; #$Expect::Debug = 1; my $timeout = 10; my $command = 'telnet'; my $params = '10.123.125.13'; my $exp = Expect->spawn($command, $params) or die "Cannot spawn sftp command"; $exp->expect($timeout, ['mpp>']); $exp->send('enable'); $exp->expect($timeout, ['mpp#']); $exp->send(&help); $exp->expect($timeout, ['mpp#']); $exp->send('exit'); $exp->send('logout'); $exp->soft_close(); sub help { print "help\n\n", "List of available commands\n", " The current commands are: \n", " enable\n", " help\n", " exit\n", " logout\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Perl Expect Command output
by armstd (Friar) on Aug 28, 2011 at 18:00 UTC | |
by anilhpn (Initiate) on Sep 15, 2011 at 18:11 UTC | |
by sugarboy (Beadle) on Mar 02, 2016 at 09:17 UTC |
In Section
Seekers of Perl Wisdom