Subject: Re: shell exec and parseing

Re: shell exec and parseing

From: Mikhail Gusarov <dottedmag_at_dottedmag.net>
Date: Sat, 30 Jan 2010 10:24:33 +0600

Twas brillig at 16:25:18 29.01.2010 UTC-08 when gougolith_at_gmail.com did gyre and gimble:

 AM> I am trying to write a user interface for a network backup utility. So all
 AM> my user interface does is executes the apps on the remote servers and then
 AM> the apps takes care of the backups. So it's a mess because once the
 AM> execution starts there is very little the interface can do to control the
 AM> apps, basically just sit back and hope it all goes well. So I read stderr
 AM> and stdin from ssh channel to get progress and such, but with the /bin/sh
 AM> method it's hard to know whether the process even finished because i need to
 AM> monitor processes with shell commands like ps and echo i guess. But most
 AM> importantly I need to know at least every second if the process is running
 AM> so i need to issue echo $ to get a pid. Anyways there are my obstacles, I
 AM> would hate using shell commands to get that kind of info cause it's
 AM> cumbersome but what else can i do ?

Instead of opening a shell (which is a "shell" request) and handling the
parsing etc, you can run an "exec" request which executes single command
and terminates. Exit status is returned (at least it SHOULD (per RFC) be
returned).

Note that you do not need to open new session each time, it is enough to
establish a session once and then "exec" requests in sequence and even
concurrently.

-- 
  http://fossarchy.blogspot.com/

_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel

Received on 2010-01-30