The group helped me to get this small snippet working ..
and it works good for when I need to telnet to multiple and/or all servers.
#! /opt/perl5/bin/perl
# example using Telnet.pm to servers
require 'Telnet.pm';
# script server ip username password
$t = new Net::Telnet Timeout => 5,
Prompt => '/[\$#%:>] $/';
$t->open($ARGV[0]);
$t->login($ARGV[1], $ARGV[2]);
@lines = $t->cmd("/usr/bin/who");
print @lines;
I am trying to get it to work for network devices. Im trying to get it going on a
router not running tacacs (first).
I continually fail at line 14.
The second problem is that if I comment out lines 13 through 19 in attempt to test vty
access only. The output is "1"
#! /opt/perl5/bin/perl
# example using Telnet.pm to telnet to net devs
require '/tools/mns/bin/Telnet.pm';
# script router or ip vty ena ;
$host = "10.10.10.2";
$pass1 = "vtypassword";
$pass2 = "enablepassword";
$t = new Net::Telnet Timeout => 10,
Prompt => '/[\$#%:>] $/';
10 $t->open($host);
11 $t->waitfor('/Password: $/i');
12 $t->print($pass1);
13 #$t->cmd($pass1);
14 $t->waitfor('/> $/i');
15 $t->print(en);
16 #$t->cmd(en);
17 $t->waitfor('/Password: $/i');
18 $t->print($pass2);
19 #$t->cmd($pass2);
20 @lines = $t->print("sh ip access-list 2");
21 print @lines;
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]