in reply to capturing stderr of echo piped to a file
Your redirection is in the wrong order:
my $command = "echo $writeline >> $file"; my $output = `$command 2>&1`;
Writing that out, you end up with
my $output = `$command echo $writeline >> $file 2>&1`;
Which means redirect STDOUT to the file, then STDERR to (current) STDOUT, i.e. also to the file. You probably want
my $output = `$command echo $writeline 2>&1 >> $file`;
instead, i.e. redirect STDERR to STDOUT, then STDOUT (but not the redirected STDERR) to the file.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: capturing stderr of echo piped to a file
by boftx (Deacon) on Oct 29, 2014 at 18:58 UTC | |
by Crackers2 (Parson) on Oct 29, 2014 at 19:17 UTC | |
by boftx (Deacon) on Oct 29, 2014 at 19:26 UTC | |
by Crackers2 (Parson) on Oct 29, 2014 at 20:13 UTC | |
by boftx (Deacon) on Oct 29, 2014 at 23:21 UTC | |
|
In Section
Seekers of Perl Wisdom