Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • Bash stuph (Score:3, Insightful)

       # does not work
        % perl script 2>&1 > test.out

    I'm not entirely certain why, but when you do that, only what would originally have been sent to STDOUT is redirected to test.out and your warnings will go to STDOUT. Change that to:

    %perl script > test.out 2>&1

        #works
        % perl script &> test.out

    Never seen that before, but then, I still don't understand Linux terribly well.

    • Re:Bash stuph (Score:4, Interesting)

      From man bash:

      Note that the order of redirections is significant. For example, the command

      ls > dirlist 2>&1

      directs both standard output and standard error to the file dirlist, while the command

      ls 2>&1 > dirlist

      directs only the standard output to file dirlist, because the standard error was duplicated as standard output before the standard output was redirected to dirlist.

      • It is easy to figure out if you remeber that bash does the redirections in the order specified. And that it uses dup to do the redirections, making a copy of the current file descriptor. You will get the same behavior from Perl code. open(STDERR, ">&STDOUT"); open(STDOUT, ">dirlist"); open(STDOUT, ">dirlist"); open(STDERR, ">&STDOUT");

        BTW, bash has a shorthand for redirectiny stdin and stderr together. ls &> file