Okay, there are a few similar topics to this one, but what I want to do is run a program in a screen session on a remote computer.

Taking my lead from this thread

In the hope that it is correct, I am entering the command:

ssh  [email protected] "screen -S test -d -m roslaunch startup startup_node"

which neither starts a new screen session "test" or runs my script "roslaunch startup startup_node"

I can create a remote session "test":

ssh  [email protected] "screen -S test -d -m"

But how can I then run a command in it? How is the screen -X command used with a named screen?

I have tried, based on this :

 ssh [email protected] "screen -X stuff "roslaunch startup startup_node^M" "

but again it doesn't seem to start the process remotely. Both commands work if you are already ssh'd into the remote.

I've also tried to write a script startnav.sh on my remote machine that contains screen -S nav -d -m roslaunch startup startup_node and I run it by:

ssh [email protected] -t "./startnav.sh"

This creates the screen instance however it is dead as in the following output

    ~$ ssh [email protected] -t screen -r nav
     There is a screen on:
            4506.nav    (04/06/15 12:30:09) (Dead ???)
     Remove dead screens with 'screen -wipe'.
     There is no screen to be resumed matching nav.
     Connection to closed.

Finally, I've followed the question here

and can get normal bash commands to execute, just not 'roslaunch startup startup_node'

for instance

ssh -f [email protected]  "screen -dm -S nav htop "

will launch a htop session in a separate screen on a remote machine. The -f flag seems to be important. But still doesn't work for a roslaunch or a script that contains roslaunch even though it does work if run without ssh. Additionally, for a temporal program such as sleep 10, the screen will only exist until that script is completed executing.

1 Answer 1


As in the final example in the question the problem was not with the ssh or screen environment other than several ROS-specific environment variables were not set up. This was due to ~/.bashrc not being called on the remote, which set them up for me.

Once I included the setup of specific environment variables namely

source /ros/devel/setup.sh

the system worked correctly.

Script File startnav.sh:


source ~/ros_ws/devel/setup.sh
roslaunch startup startup_node.launch

And the call to load the script file:

ssh [email protected] -f "screen -S nav -dm ./startnav.sh"

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .