pcb@usl.usl.edu (Peter C. Bahrs) (05/10/89)
How can I start a remote background job? I have tried: rsh machine 'program &' this waits on my local machine for termination rsh machine 'program &' & this gives me a background process on the local machine which I do not want. at time < command where command contains the line program & this works whenever (i want it now though) but I am no longer the parent of the job and thus cannot kill it. Any suggestions? /*------------Thanks in advance...---------------------------------------+ | Peter C. Bahrs UUCP ... !uunet!dalsqnt!usl!pcb | | The USL-NASA Project ... !cs.utexas.edu!usl!pcb | | Center For Advanced Computer Studies INET pcb@usl.usl.edu | | University of Southwestern Louisiana | | Lafayette, LA 70504 | +-----------------------------------------------------------------------*/
ccs013@castor.ucdavis.edu (Jason) (05/10/89)
In article <815@usl.usl.edu> pcb@usl.usl.edu (Peter C. Bahrs) writes: >How can I start a remote background job? Use the "net" command. syntax .... exple...: net -m <machine> '<command string>' that ought to do it..... ___ ___ __ ___ )___ __________________________________ ( | '__| (__ / / / / | II Corinthians 10:17 | \ | (__)\ __) /__/ / / +--------------------------------+ \_| Internet: jygabler@ucdavis |"Why me?!", Garion said. "Do we | | BITNET: jygabler@ucdavis | we have to go thru that again",| | UUCP: ucdavis!jygabler | the dry voice retorted. |
chris@mimsy.UUCP (Chris Torek) (05/10/89)
In article <815@usl.usl.edu> pcb@usl.usl.edu (Peter C. Bahrs) writes: >How can I start a remote background job? > >I have tried: > rsh machine 'program &' this waits on my local machine for termination Not exactly. Rather, it waits on your local machine for end-of-file (for the `pipe' [socket] it opens to the remote machine to indicate that that program is done sending output back). What you must do, then, is convince `program' to close all its open file descriptors (which are dup()s of that socket) before doing anything else. If your remote shell is `sh': rsh machine 'exec program </dev/null >/dev/null 2>&1 &' If your remote shell is `csh': rsh machine 'exec program </dev/null >&/dev/null &' If your remote shell is unknown: rsh machine 'quietly exec program' # program is run by sh, may contain redirections, etc. where `quietly' is as shown below (comments left as an exercise to the reader :-) ). N.B.: if you do not have strerror(), complain to your vendor and/or use char *strerror(e) int e; { static char u[40]; extern int sys_nerr; extern char *sys_errlist[]; if ((unsigned)e >= sys_nerr) { (void) sprintf(u, "unknown error code %d", e); return (u); } return (sys_errlist[e]); } (if it works, put it in your C library). #include <stdio.h> extern int errno; char *strcpy(), *strerror(), *malloc(); char *copy(); main(argc, argv) int argc; char **argv; { char *cmd; if (argc < 2) { fprintf(stderr, "usage: quietly prog [args ...]\n"); exit(2); } cmd = copy(argc - 1, argv + 1); switch (fork()) { case 0: closeall(); execl("/bin/sh", "sh", "-c", cmd, (char *)NULL); _exit(1); /* cannot complain anymore */ /* NOTREACHED */ case -1: fprintf(stderr, "quietly: cannot fork: %s\n", strerror(errno)); exit(1); /* default: parent */ } exit(0); } closeall() { register int i; for (i = getdtablesize(); --i >= 0;) (void) close(i); } char * copy(ac, av) int ac; char **av; { register char **p, *m; register int l = 0, n; for (p = av, n = ac; --n >= 0;) l += strlen(*p++) + 1; if ((m = malloc((unsigned)l)) == NULL) { fprintf(stderr, "quietly: cannot allocate %d bytes: %s\n", l, strerror(errno)); exit(1); } for (p = av, n = ac; --n >= 0;) { m += strlen(strcpy(m, *p++)); *m++ = ' '; } m[-1] = '\0'; return (m - l); } -- In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163) Domain: chris@mimsy.umd.edu Path: uunet!mimsy!chris
kemnitz@mitisft.Convergent.COM (Gregory Kemnitz) (05/11/89)
In article <4266@ucdavis.ucdavis.edu>, ccs013@castor.ucdavis.edu (Jason) writes: > In article <815@usl.usl.edu> pcb@usl.usl.edu (Peter C. Bahrs) writes: > >How can I start a remote background job? > > Use the "net" command. > > > syntax .... exple...: > > > net -m <machine> '<command string>' > I have seen at least four different ways of doing this on different machines: Counterpoint: nohup remote machine cmd & Convergent: nohup rcmd machine cmd & Berkeley 4.2: nohup rsh machine cmd & Now I see that some other UNIX uses "net". Does any know how V.4 will do it?? Greg Kemnitz
snoopy@sopwith.UUCP (Snoopy) (05/31/89)
In article <689@mitisft.Convergent.COM> kemnitz@mitisft.Convergent.COM (Gregory Kemnitz) writes: |> net -m <machine> '<command string>' | I have seen at least four different ways of doing this on different machines: | Counterpoint: nohup remote machine cmd & | Convergent: nohup rcmd machine cmd & | Berkeley 4.2: nohup rsh machine cmd & | Now I see that some other UNIX uses "net". The "net" command is from the old Berkeley Network which ran on 1200/9600 baud serial lines. There is also the "ns" command from the Purdue Engineering Computer Network based on 1 mega-baud digital coaxial cables: ns hostname [-l user password] "commands" And of course there is uux from the uucp world, although the commands allowed are usually limited to rmail and rnews for security reasons. _____ .-----. /_____\ Snoopy ./ RIP \. /_______\ qiclab!sopwith!snoopy | | |___| parsely!sopwith!snoopy | tekecs | |___| sun!nosun!illian!sopwith!snoopy |_________| "I *am* the next man!" -Indy
decot@hpisod2.HP.COM (Dave Decot) (06/02/89)
> > |> net -m <machine> '<command string>' > > | Counterpoint: nohup remote machine cmd & > | Convergent: nohup rcmd machine cmd & > | Berkeley 4.2: nohup rsh machine cmd & > > ns hostname [-l user password] "commands" The reason for these differences is that the SVID requires a command named "rsh", which is a restricted version of the Bourne shell. Therefore, when adding a new command for networking, one can't call it "rsh" and still remain SVID conformant. In HP-UX, we call it "remsh". Dave Decot decot%hpda@hplabs.hp.com