Re: How to detach from remote command?



root wrote:

....
I want to use rsh (or anything else) to send a command to a machine on
my lan, but I want to detach from that command so I don't have to wait
until the command finishes.
....
Suppose that every few minutes some machine on the lan
originates a task for a dedicated machine also on
the lan. The dedicated machine only deals with these
tasks. I can't have a user on each machine monitoring
the jobs.

You mean the task effectively works in the background on the remote machine,

ie you want to effectively do:


$ task &

but on the remote machine?

....

I was also thinking of a program on the remote machine
that does nothing but a fork to execute the task, but
uses setpgrp to "detach" from the forking program.

I know that last paragraph is obscure, let me explain.
Suppose I write a program vfork on the remote machine.
I call it like this:

rsh remote vfork command line to be executed

When vfork on the remote machine gets called
it sees its command line arguments as:
comand line to be executed. All vfork does
is execute those arguments via execlp. The
daughter process of vfork, however, is attached
to vfork so rsh waits for the daughter to finish.
So I want to use either setpgid or setpgrp to attach
the daughter process to another task, say the shell
under which some console is running.

I don't think setpgid() works in the way you think it does...it's use is in the processing of signals and inputting of data from a terminal (see: man setpgrp).

Mefinx the problem is that the forked remote process is keeping open the "tty" (socket) of the rsh (not ssh?) process. Your forking program will need to close [and reopen] stdin, stdout, stderr (file descriptors 0-2) [to relevant byte streams - especially stdout/stderr if you want results back somehow, if no input/output is needed, reconnect to /dev/null].

.



Relevant Pages

  • Re: Win32_Process.create fails to achieve aim
    ... remote machine it will terminate without notification to this method. ... > the graphic card to go in clone mode. ... > This command works when I execute it manually on the computer. ...
    (microsoft.public.scripting.wsh)
  • problem about executing a command without remote shell
    ... I want to execute a command on the remote machine with ssh client, ... But if I first login into the remote machine and then execute the same ...
    (comp.security.ssh)
  • Expect and rsh
    ... I have an expect script that I use to telnet into a remote machine ... to execute unix commands. ... For example, myscript takes a command, "-c", and executes it on ... When I do an rsh to a third machine, mach2, via mach1, I get ...
    (comp.lang.perl.modules)
  • Re: expect + last few arguments as one
    ... I'm trying to execute some commands on remote machines using expect ... ... I execute this script like: ... ./ssh_login.sh PASSWD IP COMMAND ... to different text file (on remote machine as well) AND here i have problem ...
    (comp.os.linux.misc)
  • Re: Remote Reboot on XP
    ... for an administrative user of the remote machine during the net use ... command, not the guest account name. ... >>>I proceed to enter Administrator as the username and> the ...
    (microsoft.public.windowsxp.work_remotely)