I am trying to write a script that will open an app once it is installed by
a policy. I have to script set to run after but no luck.
Senior Technology Specialist
1001 Front Street
San Francisco, CA 94111
415 365 3933
Rich.Dagel at landor.com
Is this policy set up to run as self-service or does it get triggered some
On 2/3/09 2:36 PM, "Dagel, Rich" <Rich.Dagel at landor.com> wrote:
Policies install under the root account, which means you're trying to open
it for a user who's not logged in.
What's the bigger picture of what you're trying to accomplish by opening an
application for a user just after install?
William M. Smith, Technical Analyst
Merrill Communications, LLC
I haven't tested this, it's just an idea off the top of my head...
Policies run as root.
An "open" command run as root won't open the item in another user's session
if [ `who | grep -c "$3"` -gt 0 ] ; then
else echo "No user is logged in"
Assuming I have my syntax right (and I'm not at a point in my day where I
can test this), this will test to see if $3 is logged in ($3 being the
username of the logged-in user as passed by Casper). If $3 is logged in,
the script will switch users to $3 from root, then run the open command.
Miles A. Leacy IV
? Certified System Administrator 10.4
? Certified Technical Coordinator 10.5
? Certified Trainer
Certified Casper Administrator
miles.leacy at themacadmin.com
This is probably not a good idea (if it will even let you) since these scripts are run as root. If you do succeed in opening an app like that it will most likely open in the root context which is a really really really bad idea.
One thing you could try is su'ing as the user.
USER=$3 # From Casper
su $USER -c "open /Applications/Utilities/MyApp.app"
su $USER -c "/Applications/Utilities/MyApp.app/Contents/MacOS/MyApp"
A lot of times open doesn't like being run from a script unless it is run from the current GUI user.
UW - Stevens Point
Ryan.Harter at uwsp.edu
Wanted to expand upon this. I used "Packages" to create an installer for Universal Type Client, so I could add a launchagent, and config file for the app.
Now I'm trying to find a way to, after the script that launches the installer, it then opens the app once it's done.
UTC installs fine on it's own so Packages may not be the best way to do this.
I've read that shell scripts will run each command sequentially, waiting for the previous command to finish before running the next.
so these commands should install the app, then when it's done, open it, correct?
#!/bin/sh # Determine working directory install_dir='dirname$0' # Install Universal Type Client 6.1.7.pkg /usr/bin/installer -dumplog -verbose -pkg $install_dir/"Universal Type Client 6.1.7.pkg" -target "$3" # Open app after install /usr/bin/open -a /Applications/Universal Type Client.app exit 0