Unix Programming - ssh remote execution

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > September 2005 > ssh remote execution





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author ssh remote execution
Bader

2005-09-29, 2:55 am

it is mentioned in the manual pages of ssh(1) that

" The session terminates when the command or shell on the remote
machine exits and all X11 and TCP/IP connections have been closed."

I wrote a program which create a sub-process the sub-process will then
start another program remotely on another host. I was able to do that
using the following call after I fork another process

execl("/bin/ssh","ssh","user@host","~/dir/remoteprog",0);

However the process on the local host will not exit because of the way
remote execution is designed in ssh.

Is there a way to get around this and close the session before the
remote program finishes its execution.

Thanks in advance

Chuck Dillon

2005-09-29, 6:00 pm

Bader wrote:
> it is mentioned in the manual pages of ssh(1) that
>
> " The session terminates when the command or shell on the remote
> machine exits and all X11 and TCP/IP connections have been closed."
>
> I wrote a program which create a sub-process the sub-process will then
> start another program remotely on another host. I was able to do that
> using the following call after I fork another process
>
> execl("/bin/ssh","ssh","user@host","~/dir/remoteprog",0);
>
> However the process on the local host will not exit because of the way
> remote execution is designed in ssh.
>
> Is there a way to get around this and close the session before the
> remote program finishes its execution.


You need to put the program you run on the remote box in the
background. Redirect stdout, stderr and stdin to/from somewhere other
than the pseudo-terminal ssh provides, e.g. /dev/null. You may want to
call it via nohup(1) as well.

-- ced

>
> Thanks in advance
>



--
Chuck Dillon
Senior Software Engineer
NimbleGen Systems Inc.
Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com