views:

29

answers:

3

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 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".

A: 

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.

Patrick
+2  A: 

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$'
Andy Mortimer
A: 

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.

sixtyfootersdude