[opensuse] start firefox from script
Hello: I would like to start firefox browser from bash script. I made this script: #! /bin/bash ffpid=`pidof firefox` ffexit=$? echo "firefox PID is: $ffpid" if test $ffexit == 0 then `kill -9 $ffpid` fi sleep 5 firefox -P list http://lists.opensuse.org/opensuse/2016-05/all.html & exit What I want is to check if firefox is running, if it's runing stop it and start it again with specific profile with specific URL. This works with the above script but the problem is if I run the script at least two times, the second time firefox opens with two tabs, with the same content in both tabs. How can I force it to open only on tab with the URL in the command line specified? In firefox preferences I've set General/Startup: When firefox start: Show a blank page. I use an old firefox version (24.8.1 ESR, the last ESR that doesn't have australis uinterface), I don't know if it matters. Thanks in advance, Istvan -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 2016-05-16 21:01, Istvan Gabor wrote:
Hello:
I would like to start firefox browser from bash script. I made this script:
#! /bin/bash
ffpid=`pidof firefox` ffexit=$?
echo "firefox PID is: $ffpid"
if test $ffexit == 0 then `kill -9 $ffpid` fi
sleep 5
firefox -P list http://lists.opensuse.org/opensuse/2016-05/all.html &
exit
What I want is to check if firefox is running, if it's runing stop it and start it again with specific profile with specific URL. This works with the above script but the problem is if I run the script at least two times, the second time firefox opens with two tabs, with the same content in both tabs. How can I force it to open only on tab with the URL in the command line specified? In firefox preferences I've set General/Startup: When firefox start: Show a blank page. I use an old firefox version (24.8.1 ESR, the last ESR that doesn't have australis uinterface), I don't know if it matters.
Guessing. You have to verify that the second time it really obtains the PID of the running firefox. Then you have to verify that it is killed, and wait till it does die (not five seconds), and if it doesn't, abort with message. Suggest kill, then loop till PID is not found. Also suggest do not use kill 9, but a normal kill. -- Cheers / Saludos, Carlos E. R. (from 13.1 x86_64 "Bottle" at Telcontar)
"Carlos E. R."írta:
On 2016-05-16 21:01, Istvan Gabor wrote:
Hello:
I would like to start firefox browser from bash script. I made this script:
#! /bin/bash
ffpid=`pidof firefox` ffexit=$?
echo "firefox PID is: $ffpid"
if test $ffexit == 0 then `kill -9 $ffpid` fi
sleep 5
firefox -P list http://lists.opensuse.org/opensuse/2016-05/all.html &
exit
What I want is to check if firefox is running, if it's runing stop it and start it again with specific profile with specific URL. This works with the above script but the problem is if I run the script at least two times, the second time firefox opens with two tabs, with the same content in both tabs. How can I force it to open only on tab with the URL in the command line specified? In firefox preferences I've set General/Startup: When firefox start: Show a blank page. I use an old firefox version (24.8.1 ESR, the last ESR that doesn't have australis uinterface), I don't know if it matters.
Guessing.
You have to verify that the second time it really obtains the PID of the running firefox. Then you have to verify that it is killed, and wait till it does die (not five seconds), and if it doesn't, abort with message.
Suggest kill, then loop till PID is not found. Also suggest do not use kill 9, but a normal kill.
Thanks Carlos. I expreminted a little bit with starting and stopping firefox in the command line. I start firefox: firefox Then I stop it using kill:
ps -e|grep firefox 13404 pts/8 00:00:00 firefox
kill 13404 Then I start it again: firefox Now firefox opens the site that was opened before killing firefox (restores previous session). If I shutdown firefox from within firefox (close button, or file/quit) and start it again it opens with blank tab does not restore previous session. It seems that killing firefox using its pid is not equal to shutting it down. In the former case it reopens the site which was killed. How could I close firefox from a script/command line normally as if it would be closed as by a normal shutdown? Thanks, Istvan -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On Tue, 17 May 2016 02:28, Istvan Gabor <suseuser04@...> wrote:
"Carlos E. R."írta:
On 2016-05-16 21:01, Istvan Gabor wrote:
Hello:
I would like to start firefox browser from bash script. I made this script:
#! /bin/bash
ffpid=`pidof firefox` ffexit=$?
echo "firefox PID is: $ffpid"
if test $ffexit == 0 then `kill -9 $ffpid` fi
sleep 5
firefox -P list http://lists.opensuse.org/opensuse/2016-05/all.html &
exit
What I want is to check if firefox is running, if it's runing stop it and start it again with specific profile with specific URL. This works with the above script but the problem is if I run the script at least two times, the second time firefox opens with two tabs, with the same content in both tabs. How can I force it to open only on tab with the URL in the command line specified? In firefox preferences I've set General/Startup: When firefox start: Show a blank page. I use an old firefox version (24.8.1 ESR, the last ESR that doesn't have australis uinterface), I don't know if it matters.
Guessing.
You have to verify that the second time it really obtains the PID of the running firefox. Then you have to verify that it is killed, and wait till it does die (not five seconds), and if it doesn't, abort with message.
Suggest kill, then loop till PID is not found. Also suggest do not use kill 9, but a normal kill.
Thanks Carlos.
I expreminted a little bit with starting and stopping firefox in the command line.
I start firefox:
firefox
Then I stop it using kill:
ps -e|grep firefox 13404 pts/8 00:00:00 firefox
kill 13404
Then I start it again:
firefox
Now firefox opens the site that was opened before killing firefox (restores previous session).
If I shutdown firefox from within firefox (close button, or file/quit) and start it again it opens with blank tab does not restore previous session.
It seems that killing firefox using its pid is not equal to shutting it down. In the former case it reopens the site which was killed. How could I close firefox from a script/command line normally as if it would be closed as by a normal shutdown?
The command "kill" defaults to "SIGTERM" try "SIGHUP". Either "kill -s <sig-name>" or "kill -n <sig-number" "kill -<sig-number>" also works, see list via "kill -l" Shortform: "killall -1 firefox" sends any (with your uid) running firefox-processes the "SIGHUP" (numeric 1) signal. - Yamaban.
On 2016-05-17 02:39, Yamaban wrote:
On Tue, 17 May 2016 02:28, Istvan Gabor <suseuser04@...> wrote:
Shortform: "killall -1 firefox" sends any (with your uid) running firefox-processes the "SIGHUP" (numeric 1) signal.
The UID does not matter, it sends the signal to any (all) processes regardless of the user. Of course, if you are not root, you can only kill your own processes. But you can use "--user ser" to avoid the error messages. -- Cheers / Saludos, Carlos E. R. (from 13.1 x86_64 "Bottle" at Telcontar)
17.05.2016 03:28, Istvan Gabor пишет:
It seems that killing firefox using its pid is not equal to shutting it down. In the former case it reopens the site which was killed.
Try disabling browser.sessionstore.resume_from_crash. You may want to search mozilla support site for more session-related options. -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Andrei Borzenkov írta:
17.05.2016 03:28, Istvan Gabor пишет:
It seems that killing firefox using its pid is not equal to shutting it down. In the former case it reopens the site which was killed.
Try disabling browser.sessionstore.resume_from_crash. You may want to search mozilla support site for more session-related options.
That worked. Thanks! Istvan -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 05/17/2016 02:28 AM, Istvan Gabor wrote:
I start firefox:
firefox
Then I stop it using kill:
ps -e|grep firefox 13404 pts/8 00:00:00 firefox
kill 13404
Then I start it again:
firefox
Hey guys, please don't do racy ps(1) output voodoo. Firefox with that profile should only be running once, right? Why don't you do it easier and just save the PID and kill exactly that instance? ------------------- #!/bin/bash FFPIDFILE="$HOME/.ffpid" FFPROFILE='list' test -r "$FFPIDFILE" \ && . "$FFPIDFILE" test "$FFPID" \ && kill "$FFPID" 2>/dev/null \ && wait "$FFPID" firefox -P "$FFPROFILE" --new-window "$@" & echo "FFPID=$!" > "$FFPIDFILE" ------------------- Just call it with the URL as parameter. Have a nice day, Berny -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 05/17/2016 08:47 AM, Bernhard Voelker wrote:
------------------- #!/bin/bash
FFPIDFILE="$HOME/.ffpid" FFPROFILE='list'
test -r "$FFPIDFILE" \ && . "$FFPIDFILE"
test "$FFPID" \ && kill "$FFPID" 2>/dev/null \ && wait "$FFPID"
sorry, 'wait' does not work here, but I think you got the idea, right? I'd replace the last line with the following: && while kill -0 "$FFPID" 2>/dev/null; do sleep .2; done
firefox -P "$FFPROFILE" --new-window "$@" & echo "FFPID=$!" > "$FFPIDFILE" -------------------
Have a nice day, Berny -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On 05/16/2016 09:01 PM, Istvan Gabor wrote:
Hello:
I would like to start firefox browser from bash script. I made this script:
#! /bin/bash
ffpid=`pidof firefox` ffexit=$?
echo "firefox PID is: $ffpid"
if test $ffexit == 0 then `kill -9 $ffpid` fi
sleep 5
firefox -P list http://lists.opensuse.org/opensuse/2016-05/all.html &
exit
What I want is to check if firefox is running, if it's runing stop it and start it again with specific profile with specific URL. This works with the above script but the problem is if I run the script at least two times, the second time firefox opens with two tabs, with the same content in both tabs. How can I force it to open only on tab with the URL in the command line specified? In firefox preferences I've set General/Startup: When firefox start: Show a blank page. I use an old firefox version (24.8.1 ESR, the last ESR that doesn't have australis uinterface), I don't know if it matters.
Thanks in advance,
Istvan
I'm not yet 100% sure what you want to achieve, i.e. what should happen with the previous tab(s), but I'd look at the other options mentions in --help output; some sound promising: --no-remote Do not accept or send remote commands; implies --new-instance. --new-instance Open new instance, not a new window in running instance. ... --browser Open a browser window. --new-window <url> Open <url> in a new window. --new-tab <url> Open <url> in a new tab. --private-window <url> Open <url> in a new private window. Maybe you even need to kill your normal browser window (running with a different profile). Have a nice day, Berny -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
Bernhard Voelker írta:
On 05/16/2016 09:01 PM, Istvan Gabor wrote:
Hello:
I would like to start firefox browser from bash script. I made this script:
#! /bin/bash
ffpid=`pidof firefox` ffexit=$?
echo "firefox PID is: $ffpid"
if test $ffexit == 0 then `kill -9 $ffpid` fi
sleep 5
firefox -P list http://lists.opensuse.org/opensuse/2016-05/all.html &
exit
What I want is to check if firefox is running, if it's runing stop it and start it again with specific profile with specific URL. This works with the above script but the problem is if I run the script at least two times, the second time firefox opens with two tabs, with the same content in both tabs. How can I force it to open only on tab with the URL in the command line specified? In firefox preferences I've set General/Startup: When firefox start: Show a blank page. I use an old firefox version (24.8.1 ESR, the last ESR that doesn't have australis uinterface), I don't know if it matters.
Thanks in advance,
Istvan
I'm not yet 100% sure what you want to achieve, i.e. what should happen with the previous tab(s),
Thanks. I expect that when the browser is restarted, only one tab is opened with the URL specified on the command line. I need this because I want to record flash streams which can be played in a browser. I need only one flash stream opened at at time or else they interfere. but I'd look at the other options mentions
in --help output; some sound promising:
--no-remote Do not accept or send remote commands; implies --new-instance. --new-instance Open new instance, not a new window in running instance. ... --browser Open a browser window. --new-window <url> Open <url> in a new window. --new-tab <url> Open <url> in a new tab. --private-window <url> Open <url> in a new private window.
All these options are useless in my case as I need exactly only one browser window with only one site/tab opened at a time. Either a separarate window or a second tab interferes (the sound from the stream) with the other one.
Maybe you even need to kill your normal browser window (running with a different profile).
The script kills the browser. When it starts again it should open only one site in one tab. But in my case it opens two tabs: the one was opened before closing the browser and another one which is specified on the command line. Thanks, Istvan -- To unsubscribe, e-mail: opensuse+unsubscribe@opensuse.org To contact the owner, e-mail: opensuse+owner@opensuse.org
On Tue, 17 May 2016 01:57, Istvan Gabor <suseuser04@...> wrote:
Bernhard Voelker írta:
On 05/16/2016 09:01 PM, Istvan Gabor wrote:
Hello:
I would like to start firefox browser from bash script. I made this script:
#! /bin/bash
ffpid=`pidof firefox` ffexit=$?
echo "firefox PID is: $ffpid"
if test $ffexit == 0 then `kill -9 $ffpid` fi
sleep 5
firefox -P list http://lists.opensuse.org/opensuse/2016-05/all.html &
exit
What I want is to check if firefox is running, if it's runing stop it and start it again with specific profile with specific URL. This works with the above script but the problem is if I run the script at least two times, the second time firefox opens with two tabs, with the same content in both tabs. How can I force it to open only on tab with the URL in the command line specified? In firefox preferences I've set General/Startup: When firefox start: Show a blank page. I use an old firefox version (24.8.1 ESR, the last ESR that doesn't have australis uinterface), I don't know if it matters.
Thanks in advance,
Istvan
I'm not yet 100% sure what you want to achieve, i.e. what should happen with the previous tab(s),
Thanks.
I expect that when the browser is restarted, only one tab is opened with the URL specified on the command line. I need this because I want to record flash streams which can be played in a browser. I need only one flash stream opened at at time or else they interfere.
but I'd look at the other options mentions
in --help output; some sound promising:
--no-remote Do not accept or send remote commands; implies --new-instance. --new-instance Open new instance, not a new window in running instance. ... --browser Open a browser window. --new-window <url> Open <url> in a new window. --new-tab <url> Open <url> in a new tab. --private-window <url> Open <url> in a new private window.
All these options are useless in my case as I need exactly only one browser window with only one site/tab opened at a time. Either a separarate window or a second tab interferes (the sound from the stream) with the other one.
Maybe you even need to kill your normal browser window (running with a different profile).
The script kills the browser. When it starts again it should open only one site in one tab. But in my case it opens two tabs: the one was opened before closing the browser and another one which is specified on the command line.
A few things come to mind: 1. there is a command called "killall" and it has a man-page 2. when a firefox starts with more than one tab, and you do not want that, you have a problem with your settings. Let's have a look at that: Settings/Preferences dialog: in Tab "General" -> "Start" Label "when firefox is started, open:" select "empty page" and as "Startpage" enter "about:blank" (which is a empty page) Then in a new tab enter "about:config" as location (if a warning comes, select "I'll be careful") in the "searchbar" enter "tab.url" (without the quotes) now a line with the name "browser.newtab.url" should be shown either double-left-click on the value-field, or right-click and select "edit", change the value to "about:blank" restart the browser, and it should start with just a empty page. the "empty page" is handled special by firefox, in that it will be overwritten by the url you give firefox on the command line. - Yamaban.
participants (5)
-
Andrei Borzenkov
-
Bernhard Voelker
-
Carlos E. R.
-
Istvan Gabor
-
Yamaban