On Mar 27, 2009, at 8:42 AM, Jerry Krinock wrote: > > On 2009 Mar 27, at 05:01, Eric F Crist wrote: > >> Sometimes, you need to add a few w's to the command to parse it >> properly: > > Yes, it took me about 5 years of using bash to learn why ps didn't > always work. > > Anyhow, thanks Christoph. I was hoping there might be something > that would identify an app from Launch Services database, but then > I figured that since I'm mainly concerned with false alarms and can > tolerate misses, I could use ps and grep... > > # Assume that $appName is both the package name and the executable > # name of the desired app. Warning: Either or both of these > # assumptions can be wrong. > appsRunning=`ps -alxww | grep -c "$appName.app/Contents/MacOS/ > $appName"` > # If $appName is running, results count will be 2, the second > # one being the grep process itself. Subtract that one. > let "appsRunning -= 1" > if (($appsRunning > 0)) > then > echo "$appName is running" > else > echo "$appName is not running" > fi I think you may be assuming too much. Many application packages for OS X contain many binaries. Tunnelblick is an OpenVPN GUI front-end, which contains a few of them. For example, there's the GUI application itself, which provides an icon in the menu bar. In addition, there is the actual openvpn binary, which creates the VPN connection. Either of them can be running without the other. Other applications have 'helper' apps. Missing Sync for Blackberry, for instance, has an application that runs in the background keeping track of the time and auto-starting the main application for sync operations. In either case, there are multiple binaries running, independent of the others. Keep this in mind when building your script. --- Eric Crist