Bourne 脚本:重定向成功消息,但不重定向错误消息
此命令:
keytool -import -file "$serverPath/$serverCer" -alias "$clientTrustedCerAlias" -keystore "$clientPath/$clientKeystore" -storepass "$serverPassword" -noprompt
Will 当它成功运行时输出:证书已添加到密钥库
我尝试使用以下命令重定向标准输出:
keytool ... > /dev/null
但它仍在打印。
该消息似乎正在输出到标准错误中。因为当我这样做时,它不会显示:
keytool ... > /dev/null 2>&1
但这不是我想要做的。我希望错误消息能够正常输出,但我不希望“成功”消息输出到命令行。有什么想法吗?无论 Unix 约定发生了什么:“如果它有效,则不输出任何内容”。
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".
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
同意,这不是 keytool 的友好行为。
如果成功消息集很小,您可以使用 grep 显式删除它们,例如
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
在软件上放置错误报告。此类脚本应该有一个
-q
或--quiet
,如果没有,我会称其为不需要的行为。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.我最终这样做了:
sun 制作 keytool 的白痴应该被解雇。有史以来最笨拙的工具。
I ended up doing this:
The moron at sun who made the keytool should be fired. Most ackward tool ever.