You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@karaf.apache.org by kmoens <kr...@yahoo.com> on 2012/01/09 14:28:18 UTC

multiple ssh commands programatically

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.

Re: multiple ssh commands programatically

Posted by Ioannis Canellos <io...@gmail.com>.
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
FuseSource

Blog: http://iocanel.blogspot.com
Apache Karaf Committer & PMC
Apache Camel Committer
Apache ServiceMix  Committer
Apache Gora Committer
Apache DirectMemory Committer


Re: multiple ssh commands programatically

Posted by kmoens <kr...@yahoo.com>.
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.

Re: multiple ssh commands programatically

Posted by Łukasz Dywicki <lu...@code-house.org>.
You can use an alias and quote sign a "\ " will do an space. Alsi you can create an alias.

Łukasz Dywicki
--
Code-House
http://code-house.org



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.