On Windows 7 I can't reproduce the exact problem, but odd things seem to happen with the output when perl calls python.
For example, if, in the python script, I *don't* redirect to NUL then I expect to see the output of the ping command in the console when I execute test.py ... and that happens.
I also expect to be able see the output of the ping command in the console when I run test.pl ... but it doesn't appear. If I change test.pl so that it uses backticks to execute test.py, then I *still* don't see the output of the ping command. But if I change test.pl so that it uses system() to execute test.py, then I *do* see the output of the ping command displayed in the console.

(On the basis if this, I'm wondering whether using system() might improve things for you.)

If I want to use either backticks or qx// to execute test.py, then in order to be able to view the output of the ping command, I have to change it to os.system("ping 127.0.0.1 1>&2")
So, STDOUT is definitely being messed with when perl executes python ... but I don't know the details ... and couldn't find anything readily digestible on the subject on google.

2teez ... if you're wondering ... on Windows the ping command sends just 4 pings and exits, by default ;-)

Cheers,
Rob

In reply to Re: call python from perl cause error by syphilis
in thread call python from perl cause error by anaconda_wly

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.