jboss - 您可以在 JBoss Fuse 的 Karaf 终端中运行脚本文件吗?

标签 jboss terminal jbossfuse karaf

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

($.context 包) | grep -i felix

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

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

非常感谢

*:JBoss Fuse (6.1.0.rehat-379)

最佳答案

您可以像这样使用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()> 

关于jboss - 您可以在 JBoss Fuse 的 Karaf 终端中运行脚本文件吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28242805/

相关文章:

java - 如何使用 Maven 将 .jar 文件部署到 JBoss EAP6 服务器?

java - 什么是 JBPM?为什么要使用它?

mysql - 如何使用 CAMEL 批量处理 SQL 查询的结果?

java - 在 JBoss EAP 6.4 上的 JBoss Fuse 中为 SOAP 代理创建 Camel 路由的简单指南

apache-camel - 暂停和恢复 Camel 路线

java - 如何使用Ant和build.xml部署.war文件夹?

java - EJB 规范违规 : The message driven bean must declare one onMessage() method

c++ - 使用 xcode 的 ncurses.h 库中的 initscr() 函数错误

linux - 字典 - Fedora Linux

linux - ip和mac地址linux