Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

You didn't run the test with reversed redirection, so the above doesn't actually show anything new. Here's what I get with your code, including also a reversed order test:

~> perl foobar.pl Normal STDOUT Going to STDERR ~> echo 'Just a starting point > > ' >JGBtest.txt ~> cat JGBtest.txt Just a starting point > ~> perl foobar.pl >>JGBtest.txt 2>&1 ~> cat JGBtest.txt Just a starting point > Going to STDERR Normal STDOUT ~> perl foobar.pl 2>&1 >>JGBtest.txt Going to STDERR ~> cat foobar.pl #!/usr/bin/perl use warnings; use strict; print "Normal STDOUT\n"; warn "Going to STDERR\n"; exit; __END__ ~>

Which again shows that the redirection order does matter, and in the 2>&1 >>file case, STDERR goes to the output, not the file.

Update: And just to illustrate it in one more way...

~> perl foobar.pl >>JGBtest.txt 2>&1 & [1] 22571 ~> ll /proc/22571/fd total 0 lrwx------ 1 user group 64 2014-10-29 16:31 0 -> /dev/pts/11 l-wx------ 1 user group 64 2014-10-29 16:31 1 -> /home/user/JGBtest.tx +t l-wx------ 1 user group 64 2014-10-29 16:31 2 -> /home/user/JGBtest.tx +t ~> perl foobar.pl 2>&1 >>JGBtest.txt & [2] 22578 ~> ll /proc/22578/fd total 0 lrwx------ 1 user group 64 2014-10-29 16:32 0 -> /dev/pts/11 l-wx------ 1 user group 64 2014-10-29 16:32 1 -> /home/user/JGBtest.tx +t lrwx------ 1 user group 64 2014-10-29 16:32 2 -> /dev/pts/11 ~> cat foobar.pl #!/usr/bin/perl sleep(100);

In reply to Re^5: capturing stderr of echo piped to a file by Crackers2
in thread capturing stderr of echo piped to a file by cebundy

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 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?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2024-03-28 18:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found