Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Say there's a process (PID 1501) running on a server. the server has firefox open (as 1501).. from the remote computer, i want to send commands to PID 1501 (e.g. 1501 -new-tab ). How would I run that command over ssh?

TLDR: how do i send command line arguments to a specific pid?

share|improve this question

1 Answer 1

up vote 4 down vote accepted

You can't, in general, send command line arguments to a specific pid.

Firefox has it's own remote/command system set up which allows you to send things like -new-tab commands to a running instance. It's a while since I've looked at it, but I believe it just depends on having the DISPLAY variable set to match the one that firefox is running in.

EG, on the server, you probably have DISPLAY set to :0.0 (the first local X display). You can check this by running

echo $DISPLAY

from a terminal inside X on the server itself. If that's correct, then you should be able to ssh into the server as the same user that is running X and firefox, setting your DISPLAY to :0.0, then running firefox -new-tab http://blah/:

ssh user@server
export DISPLAY=:0.0
firefox -new-tab http://blah

However, when I've done this it generally works the other way - I am running firefox on my local machine, I ssh to a remote system, and for whatever reason run firefox -new-tab, and it opens a new tab on the firefox running on my local machine. There's no reason it shouldn't work in reverse, but it's a bit complicated.

Updated I've just tested this by sshing to another machine, then back to my local one, and it definitely works as suggested. ssh in as the same username that is already running firefox, set your DISPLAY variable correctly, then firefox remote commands will work.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.