Remote execution of a program

Nils Kassube kassube at gmx.net
Sat Sep 12 06:57:44 UTC 2009


Keith Clark wrote:
> How can I log into another computer via ssh, start a gui application,
> then log out and leave it running on the remote computer.  Is this
> even possible?

If you want to start a GUI application on the remote machine, the first 
thing you need is a running X server to display the GUI and you must be 
the owner of the display. Then you could simply start your application 
at startup of the X session and you don't need to start it remotely.

However you may need to start it remotely anyway, if the program died 
for some reason. That can be done with a command like this:

nohup sh -c 'DISPLAY=:0.0 xeyes' <&- >&- 2>&- &

The "DISPLAY=:0.0" part tells the program to start on the remote machine 
instead of your local machine. The redirections <&- >&- 2>&- are not 
really necessary but if you use them you can logout without a problem. 
Otherwise ssh will probably wait until these files are closed by the 
application.


Nils





More information about the ubuntu-users mailing list