Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Trapping diagnostic messages

by Mr. Muskrat (Abbot)
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 http://perldoc.perl.org/perlop.html#`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;


Comment on Re: Trapping diagnostic messages
Select or Download Code
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?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://967137]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2014-09-03 04:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite cookbook is:










    Results (35 votes), past polls