问题描述
我在CentOS 6.5中使用$KARAF_HOME/bin/start
在服务器模式下启动了Apache Karaf 3.0.0.然后,我想使用$KARAF_HOME/bin/client
运行几个命令,并捕获这些命令的输出,以确保命令成功运行.输出确实在我的控制台上吐出,但是我永远无法将其重定向到文件中.似乎Karaf不会向输出流或错误流写入任何内容.我尝试了以下方法:
I started Apache Karaf 3.0.0 in server mode using $KARAF_HOME/bin/start
in CentOS 6.5. Then I wanted to run several commands using $KARAF_HOME/bin/client
and also capture the output of these commands, so as to make sure the commands ran successfully. The output did get spit out on my console but I was never able to redirect it into a file. Seems like Karaf doesn't write anything to the output stream or error stream. I tried the following:
[apache-karaf-3.0.0]$ ./bin/start clean
[apache-karaf-3.0.0]$ ./bin/client "bundle:list"
Logging in as karaf
282 [pool-2-thread-3] WARN org.apache.sshd.client.keyverifier.AcceptAllServerKeyVerifier - Server at /0.0.0.0:8101 presented unverified key:
START LEVEL 100 , List Threshold: 50
ID | State | Lvl | Version | Name
------------------------------------------------------------------------------------
91 | Active | 80 | 1.8.0 | Commons Codec
92 | Active | 80 | 2.6 | Commons Lang
93 | Active | 80 | 15.0.0 | Guava: Google Core Libraries for Java
[apache-karaf-3.0.0]$ ./bin/client "bundle:list" >& bundleList
[apache-karaf-3.0.0]$ cat bundleList
null
没有任何内容写入文件bundleList
.管道输出似乎也无济于事.
Nothing got written to the file bundleList
. Piping the output doesn't seem to help either.
推荐答案
要使Aviv解决方案有效,只需使用管道,例如"bundle:list | tac -f/tmp/您的文件"
To make Aviv's solution work, simply use a pipe, e.g. "bundle:list | tac -f /tmp/yourfile"
这篇关于无法捕获Apache Karaf客户端输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!