Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Need help getting output from Telnet into a string or array

by TravisC (Novice)
on Mar 16, 2012 at 19:08 UTC ( #960047=note: print w/replies, xml ) Need Help??


in reply to Re: Need help getting output from Telnet into a string or array
in thread Need help getting output from Telnet into a string or array

Success! Kinda... Working on this for the last 4 hours and I've came up with a result. When I issue my line
@array=$telnet->cmd(string => 'ls', prompt => '/=>/');
it STOPS at the first prompt where the ls is being issued. I changed my code to
@array=$telnet->cmd(string => 'ls', prompt =>'/ls/');
my output is => (the prompt before the ls). I tested this with another switch which has a different output and had a unique word in it (free) and it produced all info up to that word which is what I believe it's supposed to do. Now I guess what my question is, why is my cmd picking up the first prompt and not the second after the output? Thanks

Replies are listed 'Best First'.
Re^3: Need help getting output from Telnet into a string or array
by pklausner (Scribe) on Mar 19, 2012 at 16:12 UTC
    If your primary concern here is controlling the switch(es), not just dabbling with Perl for Perl's sake, I recommend looking at Rancid. It offers script wrappers for various vendors and models. You only supply the device command sequence, the scripts deal with login, prompts, output redirection etc.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2019-09-16 08:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    The room is dark, and your next move is ...












    Results (186 votes). Check out past polls.

    Notices?