Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2022-01-27 11:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In 2022, my preferred method to securely store passwords is:












    Results (70 votes). Check out past polls.

    Notices?