[Casper] dock problem

Charlie Butters charlie.butters at shopko.com
Thu May 28 12:28:45 PDT 2009


John,

Don¹t know if this will help, but here is another iteration to try. I think
you definitely want to run the defaults command as the user, so using su .
In my experience when doing that, I have always used the following syntax
(your kidspiration iteration is closest to what I have used):

if [[ -e "$kidspiration" ]]; then
su - "$user" -c ³defaults write
/Users/$user/Library/Preferences/com.apple.dock
persistent-apps -array-add
Œ<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString
</key><string>/Applications/Kidspiration 2/Kidspiration
2.app/</string><key>_CFURLStringType</key><integer>0</integer></dict></dict>
</dict>¹²
fi

Don¹t know how the single/double quotes will come across in the email, but
basically, here is what I suggest trying:

* add a dash between su and $user
* add the ­c flag after $user.
* put the entire defaults command in double quotes
* put single quotes around the <dict>....</dict> directive within that
command

Again, that¹s real close to what you have tried, so it may not make a
difference, but that would be the next thing I would try.

-- 
Charlie Butters
Shopko Stores
charlie.butters at shopko.com



Date: Wed, 27 May 2009 16:07:12 -0400
From: "John McLaughlin" <John_McLaughlin at newton.k12.ma.us>
Subject: [Casper] dock problem..
To: "Casper List" <casper at list.jamfsoftware.com>
Message-ID:
    <fc.000f49c2052872be000f49c2052872be.5287400 at newton.k12.ma.us>
Content-Type: text/plain; charset="iso-8859-1"

Okay, so this is the latest status on my dock problem.  I have this script
which I can run locally on any given user and it will create a dock item
for any of these programs that are present on the system.  However, it
will not work if I launch it through Casper.  As you can see, I've tried
many different methods to get defaults to work for the logged in user but
all I see is the dock relaunching.  Does anyone have any ideas?  Has
anyone done anything like this?


#!/bin/sh


# Applications
user=`ls -l /dev/console | cut -d " " -f 4`
username=`/usr/bin/w | grep console | awk '{print $1}'`
current_user=`/usr/bin/finger -s -l | grep Login | awk '{print $2}'`
kid_pix="/Applications/Kid Pix Deluxe 4"
ttl="/Applications/Type To Learn 3"
kidspiration="/Applications/Kidspiration 2"
inspiration="/Applications/Inspiration 8"

echo "3=$3"
echo "user=$user"
echo "username=$username"
echo "current_user=$current_user"
#sleep 20

if [[ -e "$kid_pix" ]]; then
su $user defaults write /Users/macuser/Library/Preferences/com.apple.dock
persistent-apps -array-add
"<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString
</key><string>/Applications/Kid
Pix Deluxe 4/Kid Pix Deluxe
4/</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></di
ct>"
fi

if [[ -e "$kidspiration" ]]; then
su "$user" defaults write /Users/$user/Library/Preferences/com.apple.dock
persistent-apps -array-add
"<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString
</key><string>/Applications/Kidspiration
2/Kidspiration
2.app/</string><key>_CFURLStringType</key><integer>0</integer></dict></dict>
</dict>"
fi

if [[ -e "$inspiration" ]]; then
defaults write /Users/"$user"/Library/Preferences/com.apple.dock
persistent-apps -array-add
"<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString
</key><string>/Applications/Inspiration
8/Inspiration
8.app/</string><key>_CFURLStringType</key><integer>0</integer></dict></dict>
</dict>"
fi

if [[ -e "$ttl" ]]; then
defaults write /Users/$current_user/Library/Preferences/com.apple.dock
persistent-apps -array-add
"<dict><key>tile-data</key><dict><key>file-data</key><dict><key>_CFURLString
</key><string>/Applications/Type
To Learn 3/Type To Learn
3/</string><key>_CFURLStringType</key><integer>0</integer></dict></dict></di
ct>"
fi

killall Dock


exit 0


John McLaughlin
Technical Support Specialist
Newton Public Schools



More information about the Casper mailing list