ArifS has asked for the wisdom of the Perl Monks concerning the following question:
Output:use warnings; use Net::Telnet; my $Telnet = new Net::Telnet; my $InHandle = $Telnet->input_log("input.txt"); my $OutHandle = $Telnet->output_log("output.txt"); my $prmpt = '/[\w().-]*[\$#>:.]\s?(?:\(>\))?\s*$/'; $host="172.16.1.1"; $username = "user"; $password = "pass"; $enpwd = "enable"; my $telnet = Net::Telnet->new( Host => $host, Input_log => "input.log", Output_log => "output.log", Dump_Log => "dump.log", Timeout => 10); # provide host address $telnet->open("$host"); print "\n\n Connecting to $host\n"; # authentication @out = $telnet->waitfor('/Username: $/i') || next; $telnet->print($username); print "@out\n"; # for tshoot only @out = $telnet->waitfor('/Password: $/i') || next; $telnet->print($password); print "@out\n"; # for tshoot only # if enable, send "enable" and enable-pwd unless ($telnet->waitfor('/Username: $/i' | '/#/i')) { #$telnet->waitfor('/>/'); @out = $telnet->print('enable'); print "@out\n"; # for tshoot only @out = $telnet->print($enpwd); print "@out\n"; # for tshoot only } print "username, password, & enable mode authentication accepted-\n"; $telnet->close;
I get the username and password passes thru in Scenario 1 but gets stuck in enable. Scenario 2 with .1.2 it doesn't like @out = $telnet->waitfor('/Username: $/i').Connecting to 172.16.1.1 1 1 pattern match timed-out at c:\temp\dirB2D.tmp\testing 3.pl line 35 Press any key to continue . . . Connecting to 172.16.1.2 pattern match timed-out at c:\temp\dirEDA1.tmp\testing 3.pl line 26 Press any key to continue . . .
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Cannot get enable> mode to work
by Corion (Patriarch) on Sep 18, 2014 at 13:50 UTC | |
|
Re: Cannot get enable> mode to work
by VinsWorldcom (Prior) on Sep 18, 2014 at 16:16 UTC | |
by ArifS (Beadle) on Sep 18, 2014 at 16:58 UTC | |
by VinsWorldcom (Prior) on Sep 18, 2014 at 18:14 UTC | |
by ArifS (Beadle) on Sep 19, 2014 at 13:10 UTC |