my ArkHost.run() woes -- fork/dup/pipe/etc bite back

Will Partain <[email protected]>
Newsgroups gmane.comp.sysutils.ark.devel
Message-ID <[email protected]>
The 'run' method for an ArkHost runs a bit of code on the
host.  Since the beginning, the code has been:

    sh = os.popen(start_shell,'w')
    sh.write(code)

where 'start_shell' is one of:

1  /bin/sh
2  sudo -u <user> /bin/sh
3  ersh <host> /bin/sh
4  ersh <host> sudo -u <user> /bin/sh

and then we shovel the desired shell script into it.

Downsides are two:

a. the stdout/stderr of the code that gets run just flies
   about aimlessly... wouldn't it be nice to grab it and
   "plumb" it in with the normal Python-interpreter
   stdout/stderr?

b. If we do that, then it's a short step to being able to
   replace sys.stdout and sys.stderr with objects that suck
   up the data, which we can then look at.  **This is very
   very nice for testing**!  (Urgh; this is a potential
   upside, not a downside...)

I've messed around with two sets of code, both of which you
will find in ARK/arkbase/ark/utils.py (next to host.py).

- runCmd() is some code of Jonathan's that does
  fork/exec/dup/close -- the full Unix thing.

- runCmd2(): something I did that isn't a long way from
  Jonathan's, except based around the Popen3 object that
  Python provides...

For reasons I cannot fathom, both of these have serious
problems with some of cases 2-4; i.e. they work for "the
obvious", but fail for the sudo/ersh cases.

I would *really* like to overcome the "downsides"... anyone
got any ideas?

Will
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.