I'm having trouble capturing errors from Net::Telnet as I would expect to. In the following code snippet, I would have thought that I would have gotten a warning 'ugh' from the cmd method, but I had no such luck. Next I would have thought for sure the error message would have been returned by the errmsg method, again no joy. The only way I see the error is if I examine what the cmd method returned to @p.
#!/usr/bin/perl -w
use strict;
use Net::Telnet;
my $user = 'foo';
my $passwd = 'bar';
my $t= new Net::Telnet(Host => '****.****.com',
Errmode => "return");
$t->login($user, $passwd);
print $t->errmsg, " login\n";
my @p=$t->cmd("dwho") or warn "ugh\n";
print $t->errmsg, " who\n";
print "\@p contains:\n", join("\n", @p),"End\n";
__END__
login
who
@p contains:
sh: dwho: not found.
End
Regardless of how I mangle the cmd, I still cannot get the errmsg method to return any error. In my actual code I,m not really concerned that the command will fail as in my example but it's quite possible that a file could be missing.
Any Ideas???
TIA
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.