SUMMARY: Doing rsh in background..

From: Richard.Dansereau@EE.UManitoba.CA
Date: Fri Nov 28 1997 - 10:24:07 CST


The original question was:

> I'm trying write some scripts that will do an rsh to a machine and
> start a long running process, but, have the rsh return right after
> starting up the process. For example, having something like
> rsh <machine> <command>
>
> The problem is that I'd like rsh to return immediately after starting
> up <command> but it seems that rsh will stick around until <command>
> has completed. I've tried things like
> rsh <machine> "<command> &"
> to put it in the background but this doesn't seem to work

This problem turns out to be because of the stdin, stdout, and stderr
being attached somehow which doesn't allow the connection to close.

I had a number of different suggestions ranging from creating a wrapper
which does the following:
   chdir /
   closeall (This turns out to matter - something I didn't realise at first.)
   fork
      parent exit

      child exec required program.

(which I didn't try, but, I believe would work properly)

And then:

rsh <machine> '<command> </dev/null >& /dev/null &' (csh)
or
rsh <machine> '<command> </dev/null > /dev/null 2>&1 &' (sh/ksh)

which seems to work perfectly for my situation. And then using the -n
option:

rsh -n <machine> <command> &

which doesn't work in my situation since this only redirects the
stdin but not the others.

I finally ended up doing:
rsh -n <machine> '(cd /mypath; command) >& /dev/null &'

Thanx to all who responded.

Cheers!
Richard..

---------------------------------------------------------------------
Richard Dansereau
Email: rdanse@pobox.com Home page: http://pobox.com/~rdanse
Electrical and Computer Engineering - University of Manitoba - Canada
---------------------------------------------------------------------



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:12:10 CDT