luxAeterna has asked for the wisdom of the Perl Monks concerning the following question:
Oh Wisest ones
I am missing something when I try to capture the return code of an execution with back ticks using $?. As far as I know, $?>>8 should contain such return code, the rest of the bits containing the number of the interruption signal if any (of no interest for me in this case).
This is a Suse operating system.
When I execute my command inside the perl code, I capture a false return code zero:
my @flush = `$command`; my $cr=$?>>8; print "$command\n"; print "Returned $cr\n";
Gives as a result:
/soft/perl-5.16.3/bin/perl /users/iax00/exploit/script/iax_0taskchklog +.pl -m --timeout='10' --success-code='0' --script='/users/iax00/expl +oit/script/iax_0tasksimp.pl' --script-prefix='${UNXEXSCRIPT}/start /s +oft/perl-5.16.3/bin/perl' --script-params='-m -v 2 --config-file /use +rs/iax00/exploit/data/iaxfcverifTomcat_admin_portal.xml' Returned 0
But when I execute the command on the shell, the return code is 5:
[mzpiax71@yval3d80]$ /soft/perl-5.16.3/bin/perl /users/iax00/exploit/s +cript/iax_0taskchklog.pl -m --timeout='10' --success-code='0' --scri +pt='/users/iax00/exploit/script/iax_0tasksimp.pl' --script-prefix='${ +UNXEXSCRIPT}/start /soft/perl-5.16.3/bin/perl' --script-params='-m -v + 2 --config-file /users/iax00/exploit/data/iaxfcverifTomcat_admin_por +tal.xml' LOGGING STYLE 1: LOGFILE /users2/iax00/log/iax_0taskchklog_20170507.lo +g. Verbosity 0 INFO - TBE Debut du job iax_0taskchklog a 2017-05-07 15:31:33 INFO - TBE Execution du script /users/iax00/exploit/script/start /soft +/perl-5.16.3/bin/perl /users/iax00/exploit/script/iax_0tasksimp.pl -m + -v 2 --config-file /users/iax00/exploit/data/iaxfcverifTomcat_admin_ +portal.xml INFO - TBE L'execution du script a genere le code de retour 5 INFO - TBE Script /users/iax00/exploit/script/iax_0tasksimp.pl pas bie +n execute. INFO - TBE Fin du job iax_0taskchklog a 2017-05-07 15:31:35 [mzpiax71@yval3d80]$ echo $? 5
This is the first time I find this problem. But thou, oh Great PerlPath Finders, may have stumbled into it before so I humbly seek for your Wisdom.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: problem retrieving return code of an execution with back ticks (updated)
by haukex (Archbishop) on May 07, 2017 at 14:39 UTC | |
by luxAeterna (Acolyte) on May 08, 2017 at 10:05 UTC | |
by haukex (Archbishop) on May 09, 2017 at 19:22 UTC |