#!/bin/sh # app_running # Checks if a specified app is running. # Note that case does matter: safari is different from Safari # Note also that this only detects processes owned by your user # - technically it checks if the process' real-uid is that of your user. # Thus, for example, it won't detect the 'loginwindow' process since that # process runs with a real-uid of 0 even through its effective-uid is that of # your user. # # Cameron Hayne (macdev@hayne.net) Oct 2006 appName=$1 echo "Checking to see if $appName is running" # Note that the "-s" option to 'killall' makes it do a "dry run" /usr/bin/killall -s $appName &> /dev/null if [ $? = 0 ]; then echo "$appName is running" else echo "$appName is not running" fi