Sunday, 15 September 2013

perl - Net::Telnet eof read waiting for login prompt: at test.pl line 25 -



perl - Net::Telnet eof read waiting for login prompt: at test.pl line 25 -

my code given below reference

#!/usr/bin/perl utilize strict; utilize net::telnet::cisco; ($host, $port, $user, $pass, $command); ##### host info print 'enter host: '; chop($host = <stdin>); ##### port info print 'enter port: '; chop($port = <stdin>); ##### user info print 'enter user: '; chop($user = <stdin>); ##### user info & hide input print 'enter password: '; scheme 'stty -echo'; chop($pass = <stdin>); scheme 'stty echo'; print "\n"; $tn = new net::telnet(host =>$host, port =>$port, timeout => 20) or die "connect failed: $!"; $tn->open ($host); $tn->login('','l@ser123'); $tn->login('$user','$pass'); @out1 = $tn->print("sh run"); print "@out1\n";

am trying login through terminal server console port , execute command facing "eof read waiting login prompt: @ test.pl line 25" error. help appreciated,thanks.

your problem first ->login method waits prompt before returning. when running telnet through terminal server (ts), never normal prompt on ts, pass straight device on console port.

if remain current configuration of ts, must clever using ->waitfor, confusing task.

what recommend reconfigure ts not authenticate telnet "pass-throughs", after it's device connected ts must protected usrname/password combo. using net::telnet::cisco assume ts cisco-device. here config using our (very old) 2511 tses, concept applies newer ciscos well:

aaa new-model ! ! normal authentication scheme (named 'default') connections terminating ! on terminal server (here via tacacs+) aaa authentication login default tacacs+ local aaa authentication enable default tacacs+ enable ! ! create authentication scheme (named 'line_auth') no authentication aaa authentication login line_auth none line 1 16 ! disable access ts serial line side, i.e allow ! *outgoing* connections no exec ! ! utilize 'line_auth' authentication scheme, i.e no authentication login authentication line_auth ! ! allow telnet connections connect line transport input telnet ! line vty 0 4 ! default authentication scheme (this default config, it's ! not shown in config). login authentication default !

perl

No comments:

Post a Comment