in reply to Need help getting output from Telnet into a string or array
Here's the lines from Net::Telnet's docs for the cmd() method that explain what's happening:
In a scalar context, the characters read from the remote side are discarded and 1 is returned on success. On time-out, eof, or other failures, the error mode action is performed. See errmode().
In a list context, just the output generated by the command is returned, one line per element. In other words, all the characters in between the echoed back command string and the prompt are returned. If the command happens to return no output, a list containing one element, the empty string is returned. This is so the list will indicate true in a boolean context. On time-out, eof, or other failures, the error mode action is performed. See errmode().
So you need to call it in list context if you want the output (assign the result to @array, not a scalar like $output).
-sam
PS: For a brand new coder your code-quality looks great!
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Need help getting output from Telnet into a string or array
by TravisC (Novice) on Mar 15, 2012 at 18:46 UTC | |
by jhourcle (Prior) on Mar 15, 2012 at 21:43 UTC | |
by TravisC (Novice) on Mar 16, 2012 at 15:28 UTC | |
by samtregar (Abbot) on Mar 15, 2012 at 19:11 UTC | |
by TravisC (Novice) on Mar 15, 2012 at 19:23 UTC | |
by TravisC (Novice) on Mar 15, 2012 at 21:49 UTC | |
Re^2: Need help getting output from Telnet into a string or array
by TravisC (Novice) on Mar 16, 2012 at 19:08 UTC | |
by pklausner (Scribe) on Mar 19, 2012 at 16:12 UTC |