[comp.unix.questions] remote background jobs

pausv@smidefix.liu.se (Paul Svensson) (12/06/88)

Problem: How do I start a background server process on another machine?
	 I have tried using rsh, but it refuses to exit when I want it to.
	 I have also looked at rexec(), but it seems to require username
	 and password info to be availiable; a real pain in the ***.

What I'm trying to do: Given a mixed network (mostly suns and goulds,
		       but also others) I would like to start a server
		       on any availiable machine; this should be done
		       only when a client notices that no server is
		       availiable - note that the machine running the
		       client is possibly not able to run the server.

Question: How do I achieve this, without leaving rsh, in.rshd or
          other processes waiting for the server to die ?

Note: I would really prefer if this could be done without installing
      something suid root, for pure beurocratic reasons.

I'd be thankful for any help, but if you're going to barf RTFM -
  _please_ at least give me a hint where to look :-)

		   /Paul
---
Paul Svensson			psv@ida.liu.se			SM5SJS

maart@cs.vu.nl (Maarten Litmaath) (12/07/88)

pausv@smidefix.liu.se (Paul Svensson) writes:

\Problem: How do I start a background server process on another machine?
\	 I have tried using rsh, but it refuses to exit when I want it to.

The following example might help:

	rsh machine -n sh -c 'server &'

The `-n' flag connects the stdin of rsh to /dev/null.
-- 
fcntl(fd, F_SETFL, FNDELAY):          |Maarten Litmaath @ VU Amsterdam:
      let's go weepin' in the corner! |maart@cs.vu.nl, mcvax!botter!maart

childers@avsd.UUCP (Richard Childers) (12/08/88)

In article <1103@smidefix.liu.se> pausv@smidefix.liu.se (Paul Svensson) writes:

>Problem: How do I start a background server process on another machine?

I've had success with the following format :

	rsh hostname "(commmand ; command -flag arg arg) &"

... or

	rsh hostname "(commmand ; command -flag arg arg) &" >& /dev/null

... if you're disinclined towards seeing process IDs ...

>I'd be thankful for any help, but if you're going to barf RTFM -
>  _please_ at least give me a hint where to look :-)

The most educational thing to do in circumstances like this is to just 'play'.
Play with it, make some mistakes, look for patterns, until you've got the
mechanism figured out. It's almost faster than reading the manual sometimes.

>Paul Svensson			psv@ida.liu.se			SM5SJS

-- richard

-- 
 *                        Black holes are out of sight                        *
 *                                                                            *
 *      ..{amdahl|decwrl|octopus|pyramid|ucbvax}!avsd.UUCP!childers@tycho     *
 *          AMPEX Corporation - Audio-Visual Systems Division, R & D          *

levy@ttrdc.UUCP (Daniel R. Levy) (12/11/88)

In article <1776@solo11.cs.vu.nl>, maart@cs.vu.nl (Maarten Litmaath) writes:
> fcntl(fd, F_SETFL, FNDELAY):          |Maarten Litmaath @ VU Amsterdam:
>       let's go weepin' in the corner! |maart@cs.vu.nl, mcvax!botter!maart

What's to weep about?  I'm curious.
-- 
|------------Dan Levy------------|  THE OPINIONS EXPRESSED HEREIN ARE MINE ONLY
| Bell Labs Area 61 (R.I.P., TTY)|  AND ARE NOT TO BE IMPUTED TO AT&T.
|        Skokie, Illinois        | 
|-----Path:  att!ttbcad!levy-----|

zifrony@TAURUS.BITNET (01/12/89)

In article <1103@smidefix.liu.se> pausv@liuida.BITNET writes:
>Problem: How do I start a background server process on another machine?
>        I have tried using rsh, but it refuses to exit when I want it to.
>        I have also looked at rexec(), but it seems to require username
>        and password info to be availiable; a real pain in the ***.
...
>
>Question: How do I achieve this, without leaving rsh, in.rshd or
>          other processes waiting for the server to die ?
...
>                  /Paul
>---
>Paul Svensson                  psv@ida.liu.se                  SM5SJS

Sorry for the late posting, but I've just reched this newsgroup.
But now to business.

I have encountered the same problem when trying to create a server process,
on another machine via 'system("rsh ....")'.  What I did, after consulting
with the local wizard was:

1. close fds 0, 1 and 2.
2. fork() - the server runs as the child process.
3. the father commits suicide.

This works just fine for me, but I guess it slows down the initialization.

Later, the initiating process on machine A, and the server process on machine
B talked using a socket.

Try it, and may god be with you.

Doron Zifrony           E-mail: zifrony@taurus.bitnet or
Msc. student                    zifrony@Math.Tau.Ac.IL
Tel Aviv University
Israel