views:

110

answers:

3

I'm testing something where I'm compiling some code and analysing output with a Perl script.

So first I run make, manually copy & paste the output to errors.txt and then running my Perl script (running: perl analysis.pl) in terminal.

Is there away I can do this just with one line in bash?

+1  A: 
echo yes && echo youcan

Yes will be echoed first, if it executes fine, then only youcan is echoed, otherwise not.

N 1.1
+5  A: 

You can do:

make > error.txt 2>&1 ; perl analysis.pl

We are redirecting the stdout and stderr of make to a file called error.txt and then irrespective of the make success or failure we are running the the Perl script( which knows to read from error.txt)

If you want the Perl script to be run only when make succeeds you can use && in place of ;

codaddict
It does what i wanted to do ... thanks all for the input :D
Jason94
+1  A: 

This should be the exact command

make > errors.txt && ./my_perl_script
tommasop
Unless you want to analyze make failures...
Randy Proctor
"pearl"? really?
Ether
HEHE Corrected!
tommasop