【问题标题】:Can't capture Apache Karaf client output无法捕获 Apache Karaf 客户端输出
【发布时间】:2014-04-21 16:39:31
【问题描述】:

我在 CentOS 6.5 中使用 $KARAF_HOME/bin/start 在服务器模式下启动了 Apache Karaf 3.0.0。然后我想使用$KARAF_HOME/bin/client 运行几个命令,并捕获这些命令的输出,以确保命令运行成功。输出确实在我的控制台上吐出,但我永远无法将其重定向到文件中。似乎 Karaf 没有向输出流或错误流写入任何内容。我尝试了以下方法:

[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。管道输出似乎也无济于事。

【问题讨论】:

标签: osgi io-redirection apache-karaf karaf


【解决方案1】:

我能够在 Karaf 版本 3.0.2 中捕获客户端输出。

user@hostname:~$ client bundle:list > bundleinfo.txt

这会在控制台上显示以下调试信息:

2053 [sshd-SshClient[36c8e545]-nio2-thread-2] WARN org.apache.sshd.client.keyverifier.AcceptAllServerKeyVerifier - 服务器在 [/0.0.0.0:8101, DSA, xx:xx:xx:xx :xx:xx:xx:c 2:3a:5a:9b:87:ed:e0:b2:6a] 提供未经验证的 {} 密钥:{}

..当然还有包含预期内容的 bundleinfo.txt 文件:

user@hostname:~$ head -5 bundleinfo.txt
START LEVEL 100 , List Threshold: 50
 ID | State    | Lvl | Version                 | Name
---------------------------------------------------------------------------------------------
38 | Active   |  80 | 3.2.5.RELEASE           | Spring Security Core
39 | Active   |  80 | 1.0.0.1                 | Apache ServiceMix :: Bundles :: javax.inject

【讨论】:

    【解决方案2】:

    对于命令行,我使用“tac”并使用 -f 重定向到一个文件,在 Karaf 3.0.3 中,尝试一下或了解它的作用 --help

    【讨论】:

    【解决方案3】:

    要使 Aviv 的解决方案发挥作用,只需使用管道,例如"bundle:list | tac -f /tmp/yourfile"

    【讨论】:

    • opendaylight 4.1.5 版不支持-f 选项的shell:tac 命令,但-a。见help shell:tac-a --append append to FILE
    猜你喜欢
    • 2014-01-08
    • 1970-01-01
    • 2016-09-24
    • 2020-06-25
    • 1970-01-01
    • 2010-11-28
    • 1970-01-01
    • 1970-01-01
    • 2012-03-29
    相关资源
    最近更新 更多