Re: bash: finding if mozilla is running

From: Aaron (aaron_at_core-dev.com)
Date: 07/29/03

  • Next message: Dan Jacobson: "only get packages that haven't changed in last 5 days"
    Date: Mon, 28 Jul 2003 19:14:11 -0400
    To: debian-user@lists.debian.org
    
    

    On -5360-Sat, Jul 26, 2003 at 02:21:52PM +0200, Sebastian Kapfer <sebastian_kapfer@web.de> spake thus,
    > On Sat, 26 Jul 2003 11:30:06 +0200, David selby wrote:
    >
    > > I need to know if mozilla is running, if not I need to call it first ...
    > > seemed simple
    >
    > Yeah. That's why I use Galeon. I never understood Mozilla's remote
    > control. :-) Of course, Galeon has other advantages, too...
    >
    > > Whatever I grep for, grep will find in ps ax as grep xxxxxx, a bit
    > > frustrating !!
    >
    > use "ps -C mozilla-bin", no grep
    >
    > --
    > Best Regards, | Hi! I'm a .signature virus. Copy me into
    > Sebastian | your ~/.signature to help me spread!
    >
    >
    > --
    > To UNSUBSCRIBE, email to debian-user-request@lists.debian.org
    > with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org

    I use a small shell script to get the behavior I'm used to from
    similar browsers in Windows where if the app is running I get a new
    tab, but if it's not it launches to the specified URL. Here it is,
    hopefully it's some help to someone (I hate it when it's already
    running and something tries to run it again to display a URL and I get
    the profile selection dialog!):

    I know there's probably a better (e.g. shorter) way to achieve this
    result, but I'm not a bash scripting master yet.

    #!/bin/bash

    # Count the number of instances of 'mozilla-bin' in my process list.
    MOZ=`ps waux | grep mozilla-bin | wc -l`

    # If there seems to be more than one instance (moz always seems to
    # start more than one thread when it's running)...
    if [ "$MOZ" -gt 1 ]; then
    # Cause the running Mozilla to open a new tab to the URL...
            `mozilla -remote "openurl($1,new-tab)"`
    else
    # Or just open a new Mozilla to the URL...
            `mozilla "$1" &`
    fi

    Cheers.

    -- 
    Aaron Bieber
    -
    Graphic Design // Web Design
    http://www.core-dev.com/
    aaron@core-dev.com
    -- 
    To UNSUBSCRIBE, email to debian-user-request@lists.debian.org 
    with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
    

  • Next message: Dan Jacobson: "only get packages that haven't changed in last 5 days"

    Relevant Pages

    • Re: grep for metacharacters
      ... tab character. ... if you want to stick with grep, ... formfeed character in a file and match based on that: ... And egrep in RHEL5 doesn't see _any_ of them: ...
      (linux.redhat)
    • Re: How Turn Auto Tab Complete Off?
      ... I used to be able to grep ... files for tab characters. ... Now, using /bin/csh (impersonated by tcsh), ... but you'll need to apply shell quoting. ...
      (comp.os.linux.misc)
    • Re: Ignoring comments and blank lines in a data file
      ... This would strip the comments, but I need to also get rid of blank lines ... The whitespace within each above is one space character and one tab ... grep won't pass it through. ...
      (comp.unix.shell)
    • Re: breaking comm results
      ... > where the space in each grep is a single tab character. ... > to strip of the extra tab character added by comm for the second file. ... You should instead use a "diff" solution, ...
      (comp.unix.shell)