fionbarr has asked for the wisdom of the Perl Monks concerning the following question:
I am using the above to run the command 'show inventory' on a router I am logging into. The command does not run, should it work? Am I going about this wrong?use strict; use warnings; use Expect; my $command = Expect->spawn("telnet 000.000.000.000"); print "looking for 'login:'\n"; unless($command->expect(10, "login:")) { die "timed out"; } print $command "<user>\n"; unless($command->expect(60, -re=> 'assword: ?')) { die "timed out"; } print $command "<password>\n"; unless($command->expect(60, -re=> 'cr.*')) { die "timed out"; } print "------------------\n"; print $command "show inventory\n"; $command->hard_close();
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: use telnet to router with expect
by RMGir (Prior) on Mar 14, 2014 at 13:18 UTC | |
by fionbarr (Friar) on Mar 14, 2014 at 13:52 UTC | |
by RMGir (Prior) on Mar 14, 2014 at 15:05 UTC | |
by RMGir (Prior) on Mar 14, 2014 at 19:16 UTC |