http://qs321.pair.com?node_id=959838


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

Replies are listed 'Best First'.
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!