Subject: Re: shell exec and parseing

Re: shell exec and parseing

From: Peter Stuge <peter_at_stuge.se>
Date: Fri, 29 Jan 2010 07:38:42 +0100

A. Mark wrote:
> What would be an easy way to check whether a process has started or
> terminated and also to get the pid of a process if I'm executing from a
> /bin/sh shell on remote host.

Sorry, but this is totally off-topic here.

These are very shell-specific questions, so please try asking them in
a shell forum instead. Note that for all the points you ask about
above, part of the answer will consistently be "/bin/sh is a user
interface" - which means it is such a waste of time to try to "remote
control" it from another program.

To come on topic a little, you could have one SSH channel and exec
per command, and easily have client state per command, as well as an
easy way to detect when programs terminate.

> but then i'll have to parse all those stray messages, so this is
> inconsistent.

Yes, because the tools you are considering are a *user* interface and
not an *application programmer's* interface.

So you want to do remote job control. This is a really big task. I
would spend a considerable amount of time on investigating existing
solutions for doing this, before rolling my own. SSH is a great
transport for anything, but /bin/sh would certainly not be something
I would use. One option would be to make a subsystem instead.

> is there a neat way to perform sscanf type reading from the input
> buffer from channel read?

Not really.

> Right now I'm using a file to write out the buffers contents then i
> read it back with fscanf discarding strings that are unknown, but
> this seems too cumbersome. Any ideas ?

Well, it can at least be made a little bit easier than that. :) Read
into a buffer and try using sscanf instead.

//Peter
_______________________________________________
libssh2-devel http://cool.haxx.se/cgi-bin/mailman/listinfo/libssh2-devel
Received on 2010-01-29