I like to test the error status of system() when I use that function. Recently I had reason to use the module Net::SSH:Expect in a program of mine. I have noticed that the value of $? after a system() call has changed to -1.
If I comment out the line "use Net:SSH:Expect" I get the results I am use to seeing a 0 for no error and 256 for error. If I uncomment "use Net::SSH:Expect" the value of $? is -1 on error or success. I am not sure what the real issue is here. Any info would be appreciated.
This is a simplistic code example of what is happening.
Bob
#!/usr/bin/perl
use strict;
use warnings;
use Net::SSH::Expect;
my $command0 = "ls -l /tmp";
my $command1 = "ls -l /temperature";
RunCmd();
sub RunCmd{
system("$command0 > /dev/null");
print "System status info is $? \n";
system("$command1 > /dev/null 2> /dev/null");
print "System status info is $? \n";
}
I got 99 problems, but a @%$()_ ain't one.
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.