Skip Menu |

This queue is for tickets about the Net-Appliance-Session CPAN distribution.

Report information
The Basics
Id: 41404
Status: resolved
Priority: 0/
Queue: Net-Appliance-Session

People
Owner: OLIVER [...] cpan.org
Requestors: victor [...] cotendo.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: wrong exit code for a script using Net-Appliance-Session version 1.32
Date: Wed, 03 Dec 2008 17:04:45 +0200
To: bug-Net-Appliance-Session [...] rt.cpan.org
From: Victor Gartvich <victor [...] cotendo.com>
Hello, Net-Appliance-Session version 1.32. A very simple script from the source package (recipe02.pl): ======================================================================== ========= #!/usr/bin/perl -w use strict; use warnings; use Net::Appliance::Session; my $ios_device_ip = 'router'; my $ios_username = 'username'; my $ios_password = 'password'; my $ios_enable_password = 'password'; my $session_obj = Net::Appliance::Session->new( Host => $ios_device_ip, Transport => 'SSH', ); # give verbose output whilst we run this script # $session_obj->input_log(*STDOUT); # try to login to the ios device, ignoring host check $session_obj->connect( Name => $ios_username, Password => $ios_password, SHKC => 0 ); # drop in to enable mode $session_obj->begin_privileged($ios_enable_password); # close down our session $session_obj->close; exit 0; ======================================================================== ========= I can successfully run the script, but the returned exit code is inconsistent: about half of the times I get code 0, and half of the time I get a strange code 255. # perl recipe02.pl ; echo $? 255 # perl recipe02.pl ; echo $? 255 # perl recipe02.pl ; echo $? 255 # perl recipe02.pl ; echo $? 0 # perl recipe02.pl ; echo $? 0 # perl recipe02.pl ; echo $? 255 # perl recipe02.pl ; echo $? 255 # perl recipe02.pl ; echo $? 0 # perl recipe02.pl ; echo $? 255 # perl recipe02.pl ; echo $? 0 # perl recipe02.pl ; echo $? 255 It looks like the 255 error code is return by the class destructor, but I have no idea what can cause a problem. Your help will be highly appreciated. Kind regards, Victor
Hi Victor, On Wed Dec 03 10:06:15 2008, victor@cotendo.com wrote: Show quoted text
> I can successfully run the script, but the returned exit code is > inconsistent: about half of the times I get code 0, and half of the > time I get a strange code 255.
I've not seen this before with Net::Appliance::Session, but I have seen this happen with other Perl programs. To be honest I am probably not enough of a UNIX expert to understand exactly what is going on, but I have two suggestions which may help... Please can you try using CORE::exit(0); instead of exit 0; in your program? I think I once resorted to that for a more consistent return value. I also seem to recall some complication with the exit code, that there are actually multiple values encoded: $exit_value = $? >> 8; $signal_num = $? & 127; $dumped_core = $? & 128; It might be that things are fine, and you are just picking up on ephemeral strangeness in the shell. I figure the CORE::exit solution might work best. I hope this helps, regards, oliver.