Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

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

by samtregar (Abbot)
on Mar 15, 2012 at 19:11 UTC ( #959838=note: print w/ replies, xml ) Need Help??


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

Is the prompt actually /=>/? That's an odd prompt. Maybe you should try '=>'? Or perhaps qr/=>/ if it's expecting a regex.

I don't know if this will be more distracting than useful, but if I was coding this I would use Expect. It takes a little getting used to but it has great debugging features.

-sam


Comment on Re^3: Need help getting output from Telnet into a string or array
Re^4: Need help getting output from Telnet into a string or array
by TravisC (Novice) on Mar 15, 2012 at 19:23 UTC
    the prompt for the switch is => fun huh... when I scale it to '=>' I get "ignoring bad Prompt argument "=>": missing opening delimiter of match operator". I'll try the expect when I can. like I've mentioned I'm new to the whole coding world, so I'm taking it one command and module at a time.
Re^4: Need help getting output from Telnet into a string or array
by TravisC (Novice) on Mar 15, 2012 at 21:49 UTC
    ok with plenty of fiddling around here's what I've been able to decipher. I pass
    my (@array)=$telnet->cmd(string => 'ls', prompt => '/=>/');
    gives be one line, which is blank. Though if I pass this line
    my ($a, $b, $c)=$telnet->cmd(string => 'ls', prompt => '/=>/');
    and print the results I get 3 lines of output so the system will pass in list context, but I fear I'm missing why it won't pass it to an array. below is the output from the a,b,c variables.
    btm.swi secondary.swi cfg/

    Any thoughts?

    thanks for all your input!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (7)
As of 2014-08-23 20:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (178 votes), past polls