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();
In reply to use telnet to router with expect by fionbarr
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |