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.


In reply to problem retrieving return code of an execution with back ticks by luxAeterna

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.