I resented the fact that I could not launch an application if another user logged into my computer had left it open. Here is the solution to launch an application another user has left active in Panther, with the example of iTunes.
#!/bin/sh
ok=`/bin/ps -auxww | /usr/bin/grep iTunes.app | /usr/bin/grep -vc grep` ; ko=1
if test $ok = $ko; then
kill `ps -ax | grep iTunes.app | grep -v grep | awk '{print $1}'`
fi
open -a "iTunes"
If you're new to shell scripting, do this:
% sudo chown root /itunes_launcher.sh
#(you will be prompted for admin password)
% sudo chmod +x /itunes_launcher.sh
% sudo chmod u+s /itunes_launcher.sh
This changes ownership of the script to root, makes it executable, and operates with root privileges when executed.
do shell script "/itunes_launcher.sh"
quit
Save your AppleScript as an application, leaving all options checkboxes blank, give it the name you want in the place you want. To launch iTunes, double-click on it.
Bonus: I wanted my AppleScript to have the same icon as iTunes and place it in my dock. Find your iTunes in folder Applications. Click on it. Hit Command-I (to open the information window). Then click on the icon. Hit Command-C (to copy the icon). Now close information window of iTunes and open that of your script. Instead of hitting Command-C, hit Command-V (to paste the icon). You're set!
Repeat step three for each of your users. This is it. Security concerned? No, iTunes won't be launched with root privileges by the shell script. The command open -a launches an application with its normal privileges.
Mac OS X Hints
http://hints.macworld.com/article.php?story=20031107063443250