I have a problem that is driving me to the brink.

I am calling an external script from a daemonized perl script. The external perl script is used to connect to a NetApp filer and get the major and minor API release level, and return in to the calling daemon.

Here's my problem. Sometimes the daemon script collects the stdout of the external, and in other cases it doesn't. However, when the external script is run from the command line, it works in all cases.

Here's my code snippet where I call the external.

my $get_version_prog = 'na_get_version.pl'; my $major_minor = qx($Bin/$get_version_prog $filer)

Both the daemon and the external use syslog to write to the application log file. Here's the final processing from the external:

syslog('notice', "Version info for $filer $major_minor"); print STDOUT $major_minor; exit 0;

and here's what I log from the daemon:

syslog('debug', "OnTap major/minor for $filer is $major_minor");

and finally, here's what shows up in the log file:

Mar 23 15:38:51 sppubu01 snapaidd[639]: [ID 702911 local7.notice] Gett +ing version info for SP1STONC02 Mar 23 15:38:53 sppubu01 snapaidd[639]: [ID 702911 local7.notice] Vers +ion info for SP1STONC02 1.31 Mar 23 15:38:53 sppubu01 snapaidd[636]: [ID 702911 local7.debug] OnTap + major/minor for SP1STONC02 is

So, the external logs the proper version info, but the print to STDOUT is not captured by the qx.

As I said before, running the external stand-alone prints the proper version info. More weird is that the daemon works as expected if the returned OnTap version from the NetApp is 1.21; it only fails if the returned OnTap version is 1.31, and only fails when being invoked through the daemon. However, the external is connecting to the NetApp, getting the proper API release, and logging it.


In reply to qx not always capturing stdout by StuLong

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.