Well, now I've done it. I've got a perl script that calls another script (it doesn't matter what language, but perl works). If I open up a command window (I'm using XP) and say:
C:> script.pl
The script executes wonderfully, and I get ALL the output of the original script ("script.pl" in this case) and the programs that the script runs. If I attempt to re-direct the output of the script like:
C:> script.pl >log_file.txt
The only thing written to the output file is the output generated by the original script ("script.pl"). The output of the decendants (system...) of "script.pl" just disappear! Now for the 'wierdness'. If I say:
C:> perl script.pl >log_file.txt
at the command line, the log file will receive all the text written by the script, and its decendants, which is the same output generated by the first example. The big question: HUH? Why does it behave differently if invoked in the various ways? In my Unix background this wouldn't be different (I'll let others verify my error if not!). I show the code for "script.pl" for reference:
#!/usr/bin/perl -w if (!defined $ARGV[0]) {$ARGV[0] = 3}; print "Argv[0] is $ARGV[0] \n"; print "Just a line to see what happens\n"; # Just to make it fun $less = $ARGV[0] - 1; if ($less) { print "Call with one less: $less \n"; system ("script.pl $less"); print "System returned $? (not that I care!)\n"; }
Yes, this is a bit silly, but it demonstrates my point. I am running on windows (XP), so forgive me. Thanks.

In reply to Inheritance of files on windows by herby1620

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.