Subject: Re: Multiple commands execution.

Re: Multiple commands execution.

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Mon, 7 Sep 2009 00:35:38 +0200 (CEST)

On Fri, 4 Sep 2009, Dmitry V. Krivenok wrote:

> My program executes many remote commands like
>
> ssh 192.168.70.205 cat /proc/meminfo | grep MemTotal | awk '{print $2}'
> ssh 192.168.70.205 cat /proc/cpuinfo | grep processor | wc -l
> ssh 192.168.70.205 uptime

ssh 192.168.70.205 "cat /proc/meminfo | grep MemTotal | awk '{print $2}'; cat
/proc/cpuinfo | grep processor | wc -l; uptime"

There. Three commands in one connection. No magic.

> The question is can I use _current_ version of libssh2? Does it support: 1)
> Creation of N "session" channels inside of SSH session and calling "exec" in
> each channel? These channels should be active simultaneously, i.e. all
> remote commands should run simultaneously.

Yes it does. Or at least should.

> 2) I consider every channel as a source of events ("new data available",
> "command exited", "command was killed by signal", "error occurred"). I want
> to implement event loop, so I need some kind of I/O multiplexing function,
> which waits for requested events. To limit maximum execution time of remote
> commands I should pass timeout to this function.

Is this a question?

libssh2 does not feature any fancy channel switch that can direct or map
actions on channels to specific events somehow. I bet that could be useful in
a scenario such as the one you describe.

> 3) If I found that remote command "hung", I should kill it via sending the
> signal (SSH_MSG_CHANNEL_REQUEST with type "signal").

I don't think it supports that.

> 4) I need to read STDOUT/STDERR of remote command and get exit status.

I think you can get those.

> I'm not sure that everything I need is already implemented in libssh2. If
> not, is it possible to implement it using facilities provided by libssh2?

Everything within the SECSH protocol is possible to implement I'm sure.

-- 
  / daniel.haxx.se
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2009-09-07