Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Net::Telnet - cant detect Passcode prompt?

by hippo (Bishop)
on Apr 05, 2016 at 21:42 UTC ( [id://1159655]=note: print w/replies, xml ) Need Help??


in reply to Net::Telnet - cant detect Passcode prompt?

For some reason net::telnet times out on the ones asking for PASSCODE

This is precisely the behaviour described in the documentation:

(the login) method performs a standard login by waiting for a login prompt and responding with $username, then waiting for the password prompt and responding with $password, and then waiting for the command interpreter prompt. If any of those prompts sent by the remote side don't match what's expected, this method will time-out, unless timeout is turned off.

The correct approach to use is also suggested by the same documentation:

Use a combination of print() and waitfor() as an alternative to login() or cmd() when they don't do what you want.
  • Comment on Re: Net::Telnet - cant detect Passcode prompt?

Replies are listed 'Best First'.
Re^2: Net::Telnet - cant detect Passcode prompt?
by Anonymous Monk on Apr 05, 2016 at 23:01 UTC
    Thanks for that. I somehow missed that it would only accept 'password'. I was able to use this code to get around this:
    $telnet->waitfor('/:/'); $telnet->print($username); $telnet->waitfor('/:/'); $telnet->cmd($password);

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1159655]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (2)
As of 2024-04-24 22:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found