multiple ssh commands programatically

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

multiple ssh commands programatically

kmoens
Hi,

I would like to send multiple SSH commands programatically, specifically to do a config:edit, config:propset MyProperty "Foo Bar" followed by a config:update.

I have seen the example with multiple commands seperated by a space, but in my case the config:propset command itself contains spaces...

And the config:edit - confi:update need to be done in 1 session.

Any help on this would be very appreciated.

Tx,

Kris
Reply | Threaded
Open this post in threaded view
|

Re: multiple ssh commands programatically

luke
You can use an alias and quote sign a "\ " will do an space. Alsi you can create an alias.

Łukasz Dywicki
--
Code-House



Wiadomość napisana przez kmoens w dniu 2012-01-09, o godz. 14:28:

Hi,

I would like to send multiple SSH commands programatically, specifically to
do a config:edit, config:propset MyProperty "Foo Bar" followed by a
config:update.

I have seen the example with multiple commands seperated by a space, but in
my case the config:propset command itself contains spaces...

And the config:edit - confi:update need to be done in 1 session.

Any help on this would be very appreciated.

Tx,

Kris


--
View this message in context: http://karaf.922171.n3.nabble.com/multiple-ssh-commands-programatically-tp3644509p3644509.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Reply | Threaded
Open this post in threaded view
|

Re: multiple ssh commands programatically

kmoens
Tx for your reply.

Found out that a simple line separator iso a space seperates different commands...

In my case I create a StringBuilder with the different commands with the separator:

sb.append("config:edit MyPID");
sb.append(System.getProperty("line.separator"));
sb.append("config:propset MyProperty MyValue");
sb.append(System.getProperty("line.separator"));
sb.append("config:update");

and use this to create the ssh channel:

channel = session.createChannel("exec", sb.toString());


Reply | Threaded
Open this post in threaded view
|

Re: multiple ssh commands programatically

iocanel
As of Karaf 2.2.5 you are able to specify the pid in all config commands as an option, which makes it easier to use from ssh.
For example you can directly use something like this in a single command:

config:propset --pid MyPID MyProperty MyValue


On 10 Ιαν 2012, at 1:26 μ.μ., kmoens wrote:

Tx for your reply.

Found out that a simple line separator iso a space seperates different
commands...

In my case I create a StringBuilder with the different commands with the
separator:

sb.append("config:edit MyPID");
sb.append(System.getProperty("line.separator"));
sb.append("config:propset MyProperty MyValue");
sb.append(System.getProperty("line.separator"));
sb.append("config:update");

and use this to create the ssh channel:

channel = session.createChannel("exec", sb.toString());




--
View this message in context: http://karaf.922171.n3.nabble.com/multiple-ssh-commands-programatically-tp3644509p3647352.html
Sent from the Karaf - User mailing list archive at Nabble.com.

Ioannis Canellos

Ioannis Canellos
http://iocanel.blogspot.com