howto write karaf shell scripts ?

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

howto write karaf shell scripts ?


I try to write scripts for the Karaf console, but examples of the documentation does not work.

I'm using Karaf 2.2.2 and Karaf 2.2.5
http://karaf.apache.org/manual/2.2.5/developers-guide/shell-syntax.html page
gives as an example
/ / Execution quotes () - similar to bash backquotes
Karaf @ root> (bundle 1) location
mvn: org.ops4j.pax.url/pax-url-mvn/1.1.3

but if I wrote this example I only error
Karaf @ root> (bundle 1) location
Command not found: bundle

/ / Add all public methods we have java.lang.System commands:
Karaf @ root> addCommand system (loadClass java.lang.System)
Command not found: loadClass
Karaf @ root> system: getproperty karaf.name
Command not found: system: getproperty

I can not get the list of files in a folder
for example I have in the "scripts" a set of script

Karaf @ root> exec ls
displays the list of file from Karaf.
Karaf @ root> exec ls scripts
displays nothing
worse if I do not restart
Karaf @ root> exec ls
does not display anything

I wanted to make a script that lists the files in this
scripts / install and executed.
something like
path = $ (pwd)
cd scripts / install /
ls -1 *. sh | while read script;
   source $ {script};
cd $ {path}

but I did not find complete documentation on the syntax. just flanges.
As a variable to the result of the pwd command?
Karaf @ root> path = (exec pwd)
Karaf @ root> echo $ path
Karaf @ root>

how to read the names of all files in a folder?
how to get their names?
where i can find a complet documentation ?