You said you don't care about the other information in $?, but I'd say that's not a good way to look at it, since I assume you do want to know whether your script completed successfully or not. So you should always check $? against zero first, and then you can inspect its value to see what went wrong. See the example code in system (slightly reformatted for brevity):

if ($? == -1) { print "failed to execute: $!\n" } elsif ($? & 127) { printf "child died with signal %d, %s coredump\n", ($? & 127), ($? & 128) ? 'with' : 'without' } else { printf "child exited with value %d\n", $? >> 8 }

Or, easier, use capture or (better) capturex from IPC::System::Simple, which has very good handling of these errors built in. I wrote about the topic of running external commands at length here.

One more small thing is - have you inspected the command's output in @flush?

There is also a small possibility that the shell that Perl is using to execute the backticks is different from your command line shell, so there could be a difference there, which is why I recommended capturex, which doesn't invoke the shell at all. The only thing in your command that seems to need the shell's capabilities is ${UNXEXSCRIPT}*, which you can do at the Perl level with $ENV{UNXEXSCRIPT}. What I mean is something like the following (untested). Note that I've made some assumptions about how the script parses command line arguments; if you have trouble with --script-prefix or --script-params you might need to fiddle with adding quoting to them:

use IPC::System::Simple qw/capturex/; my @flush = capturex('/soft/perl-5.16.3/bin/perl', '/users/iax00/exploit/script/iax_0taskchklog.pl', '-m','--timeout=10','--success-code=0', '--script=/users/iax00/exploit/script/iax_0tasksimp.pl', '--script-prefix='.$ENV{UNXEXSCRIPT}.'/start /soft/perl-5.16.3/bin +/perl', '--script-params=-m -v 2 --config-file /users/iax00/exploit/data/i +axfcverifTomcat_admin_portal.xml');

Without knowing anything about iax_0taskchklog.pl or iax_0tasksimp.pl (the latter is returning the error code, correct?), these are just guesses - it's also possible that one or both of these scripts have code in them that causes them to act differently when run from the shell vs. run from another script (environment variables, interactive prompting, ...), and that is causing the problem.

* Update: Actually, I just noticed you said '${UNXEXSCRIPT}...', so I guess you don't want to have it expanded by the shell...? Update 2: Hm, actually it seems from your log output that the variable does get expanded, but later, so I guess inside iax_0taskchklog.pl?


In reply to Re: problem retrieving return code of an execution with back ticks (updated) by haukex
in thread 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.