开发者

how to do system() without relaying stdout in perl

开发者 https://www.devze.com 2023-01-09 04:06 出处:网络
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 wan

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)


Redirect the standard output to /dev/null:

system("xcodebuild >/dev/null") == 0
  or warn "$0: xcodebuild exited " . ($? >> 8) . "\n";


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消