10

I have a Linux machine I regularly log on to via ssh (putty) from Windows. I'm running VcXsrv X-server on my Windows desktop. I mainly use this to run a debugger (ddd) and firefox to access our web-based code review system. It's convenient to use the Linux firefox so I can launch it from a script. I normally launch this with "-new-tab" so as not to keep creating new windows.

Now I've got a new update Linux machine which I'm running alongside the old one for the time being. What I've noticed is some odd behaviour: when I launch a new firefox session if there's one already running on either machine, then it uses that.

What I'd like to be able to do is still launch as a new tab but only under the instance of firefox from the current machine, not an instance from a different machine that happens to be displaying on the same X-server.

I've been playing around with various flags including -no-remote, -new-instance and also defining and using specific profiles. However I've been unable to get the desired result. Either I get the behaviour I described above, or I get an error saying something like "Firefox is already running but not responding, please close it".

EDIT: I've been asked to edit this to provide some examples.

OK. In what follows I'll refer to M_OLD and M_NEW. These are separate machines running different versions of Linux with different versions of Firefox (1.5 and 19). I connect to them both via an ssh client called Putty and am forwarding X to an X server on my Windows desktop. There's only one X server involved.

Example 1:

So from my putty session to M_OLD I run:

firefox www.google.com &

and from my M_NEW putty session I run:

firefox www.imdb.com &

then I get one firefox 1.5 window with two tabs. If I do the same in reverse I get the same result but with firefox 19. In other words, as described in a comment below, the first command launches an instance of firefox the second simply tells the existing instance to open a new tab. Even if the instance is on another machine, so long as it's the same X server.

However I don't want this. I want to have separate instances for separate machines. So:

Example 2:

So from my putty session to M_OLD I run:

firefox -no-remote www.google.com &

and from my M_NEW putty session I run:

firefox -no-remote www.imdb.com &

Now I have two separate instances of firefox. However if I then run on M_NEW:

firefox -no-remote www.google.com &

I'll get

Firefox is already running, but is not responding. To open a new window, you must first close the existing Firefox process, or restart your system.

and even if I try

firefox -no-remote -new-instance www.google.com &

or just

firefox -new-instance www.google.com &

then I'll still get the error.

What I really want - and it may not be possible - is to have a separate instance for each machine but if a new URL is launched from that machine it opens a new tab. It seems as though I can only either have one instance with new tabs for each URL, or one instance per machine, but only one at a time.

Hopefully that's clearer.

8
  • Could you clarify? How is the new Linux machine relevant? You are forwarding X to your Windows machine right? Are you connected to both Linux boxes at the same time? Please give some more detail on how you connect to each box.
    – terdon
    Nov 7, 2013 at 16:29
  • OK, so when the issue occurs you are connected to both machines with ssh -X correct?
    – terdon
    Nov 7, 2013 at 17:38
  • Yes I'm forwarding X to my Windows machine. Yes I'm connected to both. The new machine is relevant because I'm also launching firefox from it. However instead of launching a new instance of firefox it opens a new tab in the existing instance - the one that was launched from the old machine. It's as if the new firefox process checks to see if firefox is running on that X server and if so sends it a message to open a new tab. Which is very clever but not what I want. The "old" and "new" is relevant only in so far as they are very different versions of firefox. Make sense?
    – PaulM
    Nov 7, 2013 at 17:42
  • 1
    What you're describing is normal (as I found out to my surprise), I don't get how it's not fixed when running with --no-remote though. Could you edit your question and tell us when you get the "Firefox already running" message? Running firefox -no-remote should start a new firefox instance running on the remote machine but displayed on your local X server.
    – terdon
    Nov 7, 2013 at 17:47
  • 1
    I think you may also have to add -p e.g. -p -no-remote. This allows to start with a new Fx profile. See Command line options. To connect to the existing Fx process you could try firefox https://www.mozilla.org or firefox -remote "openURL(https://www.mozilla.org, new-tab)"
    – vWil
    Nov 12, 2013 at 4:28

4 Answers 4

1

Distinct Firefox instances (eg created with --no-remote) must have separate profiles.

Option 1: Create two (or more) profiles, one for each system running Firefox. Example

firefox --no-remote -CreateProfile localuser
firefox --no-remote -CreateProfile host2

Now start firefox and select a profile at startup

firefox --no-remote -P localuser

or

firefox --no-remote -P host1

Option 2: Set up dynamic solution to create a "disposable" profile on startup, eg a scrupt along the lines of:

TEMPPROFILE=$(date +%Y%m%d%H%M%S)
firefox --no-remote -CreateProfile $TEMPPROFILE 2>/tmp/.mozprofile.$TEMPPROFILE
firefox --no-remote -P $TEMPPROFILE

You may want to add steps to remove the temporary profile afterwards (The direcotry to remove can be found by parsing the output from the CreateProfile command, stored via the above command in /tmp/.mozprofile.$TEMPPROFILE

4
  • already tried that - see "example 2"
    – PaulM
    Jan 15, 2014 at 11:04
  • Ah yes, true - distinct instances have to use different profiles.
    – Johan
    Jan 16, 2014 at 11:01
  • The first "option" you proposed didn't make any sense at all, really, so I've proposed it be removed from your answer.
    – SamB
    Jan 21, 2014 at 0:31
  • Though, actually, it might work without the -no-remote ...
    – SamB
    Jan 21, 2014 at 0:56
0

Ok...don't know if this will work, but it's the first thing I'd try:

How about if you create a second script on each machine, which doesn't try to create the new tab, just a new instance. If you don't have FF currently running on that machine, you use this new script, but if it's already running, you use the old script that creates the new tab.

If this works, you might be able to do some regex parsing of ps output in a single script to see if FF is already running on the machine, and either use the -new-tab switch or -no-remote, depending on what it finds; but you probably want to wait until this method is tested, as it's a fair amount of coding for something that might not work....

1
  • that sounds like it might work - but tbh I gave up on this. M_OLD is being decommissioned soon.
    – PaulM
    Jan 15, 2014 at 11:07
0

Looking at XRemoteClient.cpp, I think you should do:

user@host1$ firefox -CreateProfile profile1

and:

user@host2$ firefox -CreateProfile profile2

Then, when you want to go somewhere, do something like

user@host1$ firefox -P profile1 -new-tab http://example.com

or, well, I think you can guess what to do on host2.

Obviously, you can pick better names. It also shouldn't much matter how you create the profiles. The important thing being to specify a profile name on the command line every time you invoke it, where each instance has its own profile name.

This might even work.

0

I have a quite elegant solution here if you still need. For now I have, like, 5 independent instances of firefox running and as much as I want.

You must log in to answer this question.

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