You are not logged in.

#1 2014-12-06 09:19:12

Arakis
Member
From: Hamminkeln - Germany
Registered: 2013-08-11
Posts: 46
Website

Exec command via SSH in existing X-Session

Hello,
i want to start the media player app via SSH in an existing X-Session (real display) on the ssh target (ssh user = x-session user, all same machine). I do not mean X-forwarding! After the app is started, i want to disconnect the ssh connection and all should be still running. Any ideas?

Greetings,
Sebastian

Offline

#2 2014-12-06 09:40:08

th3voic3
Member
Registered: 2012-03-20
Posts: 92

Re: Exec command via SSH in existing X-Session

Start a tmux or screen session. Then do a

export DISPLAY=:0

Then run your command, detach from the screen or tmux session and you can safely end the ssh session.

Offline

#3 2014-12-11 14:28:17

Arakis
Member
From: Hamminkeln - Germany
Registered: 2013-08-11
Posts: 46
Website

Re: Exec command via SSH in existing X-Session

Thank you, this worked. I thougth all the time, "export DISPLAY=:0" will export it to my local display, like with x-forwarding?

By the way, using tmux/screen is not requied, you can simply add a "&"-char at the end of the command, that it will run detached from the console.

Offline

#4 2014-12-11 15:11:15

Awebb
Member
Registered: 2010-05-06
Posts: 6,311

Re: Exec command via SSH in existing X-Session

The difference:

#remote display
ssh user@host DISPLAY=:0 some_command

# although you might assume it get's passed through ssh, it does not and is displayed on the remote machine
ssh -X user@host DISPLAY=:0 some_command

# local display
DISPLAY=:0 ssh -X user@host some_command

Also have a look at the man pages of disown and nohup to learn how to remove the program from your running shell, so you can close the ssh connection.

By the way: export only means, that the variable is exported to the shell. If I run "export TERMINAL=xterm", then until I close the shell, I can for example "echo $TERMINAL" to read "xterm". The shell is always on the host you are connected to. I assume there is a way to bind a remote X server to a DISPLAY (say :100), so you could DISPLAY=:100 to automatically show it on the remote host (or your local host, depending on what machine you sit in front of). I only assume because there is always a way, but I have never tested it or really thought about it.

Offline

Board footer

Powered by FluxBB