Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: Trapping diagnostic messages

by Mr. Muskrat (Canon)
on Apr 25, 2012 at 18:13 UTC ( #967137=note: print w/replies, xml ) Need Help??

in reply to Trapping diagnostic messages

If my Google searches results are correct, the "SAM header is present" line comes out on STDOUT. The backticks will capture STDOUT by default but with some redirection, we can make it only capture STDERR where real errors should show up. See`STRING` for more details.

# discard STDOUT but capture STDERR in @out my @out = `/home/applications/samtools-0.1.7a/samtools view -bS $ARGV[ +0] 2>&1 1>/dev/null`; print OUT @out;

If you really do want the "SAM header is present" line to come out on STDOUT then you could do something like this.

# redirect STDOUT to stdout.log and capture STDERR in @out my @out = `/home/applications/samtools-0.1.7a/samtools view -bS $ARGV[ +0] 2>&1 1>stdout.log`; print OUT @out; my $stdout = do { local( @ARGV, $/ ) = 'stdout.log'; <> }; # slurp the + contents of stdout.log into $stdout print $stdout;

Replies are listed 'Best First'.
Re^2: Trapping diagnostic messages
by Eldan Aranye (Acolyte) on Apr 26, 2012 at 00:53 UTC
    Thank you for your reply! Actually, I tried adding 2>&1 to the command yesterday and it worked. It captured the STDOUT, thus preventing Galaxy from interpreting it as an error. Thanks again!

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://967137]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2018-02-18 06:07 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (250 votes). Check out past polls.