Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to do system() without relaying stdout in perl

Tags:

perl

How can I in perl make

system("xcodebuild");

only relay stderr, and not stdout. (xcodebuild has an enormous amount of verbosity that I want to get rid of, but when something goes wrong, I still want to know what it was)

like image 889
Lucas Meijer Avatar asked Jul 23 '10 22:07

Lucas Meijer


2 Answers

Redirect the standard output to /dev/null:

system("xcodebuild >/dev/null") == 0
  or warn "$0: xcodebuild exited " . ($? >> 8) . "\n";
like image 80
Greg Bacon Avatar answered Nov 14 '22 08:11

Greg Bacon


system("xcodebuild >> /dev/null");

...assuming, of course, that you're getting all the stderr stuff with your current syscall mechanism. Otherwise, you'll need to redirect stdout to devnull and stderr to stdout.

like image 2
Sniggerfardimungus Avatar answered Nov 14 '22 09:11

Sniggerfardimungus