Re: Firefox -remote "ping()" gone, here's a workaround
I don't see why do you workaround the problem before you make sure there's a bug report? I searched Mozilla's bugzilla and nothing is reported about ping() not working. I'm sure letting the Mozilla people find why it doesn't work is shorter than working around the problem. Please report that as a bug. Let me know if you have questions. My intent is not to lecture you, but make sure the maximum number of people will enjoy the solution. https://bugzilla.mozilla.org Yosef Meller wrote: --Boundary_(ID_4J4w7ohUWxWs9BJUbxzr4A) Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7BIT Hi, all There used to be a way of determining if firefox is running by checking the return value of: $ firefox -remote "ping()" However I tried it on 1.0 PR and it's gone. I googled for it and found a message that says the same thing so I guess it's not my problem. Anyway, I needed that, so I wrote a workaround that uses ps. The attached script is designed to open a page in firefox, but if firefox is already running, do it in a new tab. I submit this for your enjoyment and critical review. I wonder if there is a better (or simply other) way to do it. -- Regards, Lior Kaplan [EMAIL PROTECTED] http://www.Guides.co.il Debian GNU/Linux unstable (SID) = To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: Firefox -remote "ping()" gone, here's a workaround
Yosef Meller <[EMAIL PROTECTED]> writes: > ps -A does not show command line arguments Oh, I didn't realize this. Is it specified anywhere? I guess the explanation for the -f option may be read to infer that. In any case, I missed it. > > Finally, it should be relatively easy to make your script work for any > > browser that supports a variant of "-remote" option. You may pass the > > browser and the option on the command line, or via the environment, > > with "firefox" and "-remote" as default values. > > I guess you're right, but I don't know any other browser that suports that. Netscape and mozilla are the obvious ones, kfmclient exists for konqueror, and I am fairly confident that you could use w3 via emacsclient/gnuclient (though I have never tried it), and you never know what else lurks out there... -- Oleg Goldshmidt | [EMAIL PROTECTED] = To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: Firefox -remote "ping()" gone, here's a workaround
Oleg Goldshmidt wrote: Yosef Meller <[EMAIL PROTECTED]> writes: ps -A | grep -i firefox > /dev/null I think you are in danger here: your grep is a separate process and it *may* appear in the process table and be grepped (since the command line contains what you are looking for) even when firefox is not run. There is no lock that says grep does not start until ps finishes reading the process table. ps -A does not show command line arguments, so we're safe here. But see below... One useful trick is "egrep -i [f]irefox", another is "grep -v grep". RedHat have /usr/bin/pgrep and /usr/bin/pkill utilities, and I have used pname () { /bin/ps auxww | /bin/egrep "$@" | /bin/grep -v egrep } pnum () { pname "$@" | /bin/awk '{print $2}' } pkill () { kill -9 `pnum [EMAIL PROTECTED] } in my .bashrc since before RedHat introduced theirs. Another, related point: your script is only good for a single-user machine. Since "ps -A" lists *all* processes then your grep may find someone else's firefox. You will be better off parsing the long output of ps and finding your own firefox. E.g. RedHat's pgrep will allow that. OK, let's use: ps auxc | grep $USER | grep $FIREFOX The 'c' displays the true executable name without command line args, achieving much the same effect of ps -A, and I think this is a bit more elegant. Finally, it should be relatively easy to make your script work for any browser that supports a variant of "-remote" option. You may pass the browser and the option on the command line, or via the environment, with "firefox" and "-remote" as default values. I guess you're right, but I don't know any other browser that suports that. -- "No, I do not contain myself," were the final words from the set of self-excluding sets. :-) = To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Re: Firefox -remote "ping()" gone, here's a workaround
Yosef Meller <[EMAIL PROTECTED]> writes: > ps -A | grep -i firefox > /dev/null I think you are in danger here: your grep is a separate process and it *may* appear in the process table and be grepped (since the command line contains what you are looking for) even when firefox is not run. There is no lock that says grep does not start until ps finishes reading the process table. One useful trick is "egrep -i [f]irefox", another is "grep -v grep". RedHat have /usr/bin/pgrep and /usr/bin/pkill utilities, and I have used pname () { /bin/ps auxww | /bin/egrep "$@" | /bin/grep -v egrep } pnum () { pname "$@" | /bin/awk '{print $2}' } pkill () { kill -9 `pnum [EMAIL PROTECTED] } in my .bashrc since before RedHat introduced theirs. Another, related point: your script is only good for a single-user machine. Since "ps -A" lists *all* processes then your grep may find someone else's firefox. You will be better off parsing the long output of ps and finding your own firefox. E.g. RedHat's pgrep will allow that. Finally, it should be relatively easy to make your script work for any browser that supports a variant of "-remote" option. You may pass the browser and the option on the command line, or via the environment, with "firefox" and "-remote" as default values. -- Oleg Goldshmidt | [EMAIL PROTECTED] = To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]
Firefox -remote "ping()" gone, here's a workaround
--Boundary_(ID_4J4w7ohUWxWs9BJUbxzr4A) Content-type: text/plain; charset=us-ascii; format=flowed Content-transfer-encoding: 7BIT Hi, all There used to be a way of determining if firefox is running by checking the return value of: $ firefox -remote "ping()" However I tried it on 1.0 PR and it's gone. I googled for it and found a message that says the same thing so I guess it's not my problem. Anyway, I needed that, so I wrote a workaround that uses ps. The attached script is designed to open a page in firefox, but if firefox is already running, do it in a new tab. I submit this for your enjoyment and critical review. I wonder if there is a better (or simply other) way to do it. -- "No, I do not contain myself," were the final words from the set of self-excluding sets. :-) --Boundary_(ID_4J4w7ohUWxWs9BJUbxzr4A) Content-type: text/plain; name=catchthefox.sh Content-transfer-encoding: 7BIT Content-disposition: inline; filename=catchthefox.sh #! /bin/bash # catchthefox.sh # By Yosef Meller # License: GPL # # A script to launch a page in a new tab if firefox is running, # Otherwise run firefox and open the page. FIREFOX=/usr/bin/firefox HOST=localhost # Different distros have different executable name, so grep -i # For example, in Mandrake it's MozillaFirefox, in Gentoo it's just firefox. ps -A | grep -i firefox > /dev/null if [ $? -eq 0 ] then $FIREFOX -remote "openURL(http://$HOST/lib/library.cgi,new-tab)" & else $FIREFOX http://$HOST/lib/library.cgi & fi --Boundary_(ID_4J4w7ohUWxWs9BJUbxzr4A)-- = To unsubscribe, send mail to [EMAIL PROTECTED] with the word "unsubscribe" in the message body, e.g., run the command echo unsubscribe | mail [EMAIL PROTECTED]