【问题标题】:Can you run a script file within JBoss Fuse' Karaf Terminal?你能在 JBoss Fuse 的 Karaf 终端中运行脚本文件吗?
【发布时间】:2015-01-30 18:57:25
【问题描述】:

Karaf* 终端允许在提示符下编写一些命令脚本。例如:

($.context bundles) | grep -i felix

I have seen threads that discuss running multi-line scripts,大概包含在一个文件中。

我的问题很简单:如何从终端运行 karaf 语言脚本文件?对于我的应用程序,脚本可以是本地文件。

非常感谢

*:JBoss Fuse (6.1.0.rehat-379)

【问题讨论】:

    标签: jboss terminal jbossfuse karaf


    【解决方案1】:

    您可以像这样使用shell:source 命令:

    这是一个示例脚本。

    computer:karaf donald$ cat test.script  
    bundle:list -t 0 | head
    echo 'Hello world 1'
    echo 'Hello world 2'
    echo 'Hello world 3'
    

    下面是从 karaf 调用它的方法:

    Cobalt:bin donald$ ./karaf 
            __ __                  ____      
           / //_/____ __________ _/ __/      
          / ,<  / __ `/ ___/ __ `/ /_        
         / /| |/ /_/ / /  / /_/ / __/        
        /_/ |_|\__,_/_/   \__,_/_/         
    
      Apache Karaf (3.0.2)
    
    Hit '<tab>' for a list of available commands
    and '[cmd] --help' for help on a specific command.
    Hit '<ctrl-d>' or type 'system:shutdown' or 'logout' to shutdown Karaf.
    
    karaf@root()> shell:exec pwd
    /Users/donald/apache-karaf-3.0.2
    karaf@root()> shell:exec ls
    LICENSE
    NOTICE
    README
    RELEASE-NOTES
    bin
    data
    demos
    deploy
    etc
    instances
    lib
    lock
    system
    test.script
    karaf@root()> shell:source test.script
    START LEVEL 100 , List Threshold: 0
    ID | State    | Lvl | Version         | Name                                                               
    -----------------------------------------------------------------------------------------------------------
     0 | Active   |   0 | 4.2.1           | System Bundle                                                      
     1 | Active   |   5 | 2.2.0           | OPS4J Pax Url - aether:                                            
     2 | Active   |   5 | 2.2.0           | OPS4J Pax Url - wrap:                                              
     3 | Active   |   8 | 1.7.4           | OPS4J Pax Logging - API                                            
     4 | Active   |   8 | 1.7.4           | OPS4J Pax Logging - Service                                        
     5 | Active   |  10 | 3.0.2           | Apache Karaf :: Service :: Guard                                   
     6 | Active   |  10 | 1.8.0           | Apache Felix Configuration Admin Service                           
    Hello world 1
    Hello world 2
    Hello world 3
    karaf@root()> 
    

    【讨论】:

    • 非常好的例子,我确实必须将 test.script chown 给启动 karaf 的用户,并且脚本第一行中的“bundle:list”命令是“osgi:list” JBoss Fuse (6.1.0.rehat-379),但除此之外,它还可以解决问题!谢谢。
    【解决方案2】:

    创建一个文件并一次性添加所有要运行的 fuse 命令 .从 karaf 使用命令 shell:source

    Reference

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2012-01-21
      • 2017-10-10
      • 2011-09-26
      • 2023-03-18
      • 1970-01-01
      • 2020-05-27
      • 1970-01-01
      相关资源
      最近更新 更多