开发者

Bourne Script: Redirect success messages but NOT error messages

This command:

keytool -import -file "$serverPath/$serverCer" -alias "$clientTrustedCerAlias" -keystore "$clientPath/$clientKeystore" -storepass "$serverPassword" -noprompt

Will when it runs successfully outputs: Certificate was added to keystore

I tried redirecting the stdard out with:

keytool ... > /dev/null

But it开发者_StackOverflow社区 is still printing.

It appears that the message is being output into standard error. Since when I do this it is not displayed:

keytool ... > /dev/null 2>&1

However this is not what I am wanting to do. I would like error messages to be output normally but I do not want "success" messages to be output to the command line. Any ideas? Whatever happened to unix convention: "If it works do not output anything".


Agreed, that's not a friendly behaviour on the part of keytool.

If the set of success messages is small, you can use grep to explicitly remove them, eg

keytool ... 2>&1 | grep -v '^Certificate was added to keystore$'


Place a bug report on the software. There should be a -q or --quiet for these kind of scripts, if it is not, I'd call it an unwanted behavior.


I ended up doing this:

keytool ... > /tmp/keytmp 2>&1 || cat /tmp/keytmp

The moron at sun who made the keytool should be fired. Most ackward tool ever.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜