run command as current user via casper policy?

tlarkin
Honored Contributor

I want to send out a simple one line command to every client machine, but I want it to modify a file in the home directory.

defaults write com.apple.AppleShareClient "afp_cleartext_allow" -bool YES

So, how do I wild card it or loop it to hit every home directory on a machine with out making it a log in hook or what not?

Thanks,



Thomas Larkin
TIS Department
KCKPS USD500
tlarki at kckps.org
blackberry: 913-449-7589
office: 913-627-0351

2 REPLIES 2

Not applicable

I've attached and pasted FixOfficeDefaults.sh, which does just the sort of thing you are looking for. IIRC, I never did get it to show an error in the Casper logs (although you can see that it tries to); but, it does find the user and run defaults for them.

Cheers,
Clinton Blackmore

#!/bin/bash

# Applies fixes to MS office so previous formats are used by default
# Based on http://managingosx.wordpress.com/2008/02/13/managing-office-2008/

USERNAME=$3
if [ "$USERNAME" == "" ] ; then # script not called at login; find out who is using the computer USERNAME=/usr/bin/w | grep console | awk '{print $1}'
fi

if [ "$USERNAME" == "" ] ; then echo "No one is using the computer; can not set the preference." 1>&2 exit 1
else

echo "Fixing Office defaults for $USERNAME"

su $USERNAME -c 'defaults write com.microsoft.autoupdate2 HowToCheck "Manual"' #defaults write com.microsoft.office "2008FirstRun SetupAssistCompleted" -int 1 su $USERNAME -c 'defaults write com.microsoft.Word "2008Default Save Default Format" "Doc97"' su $USERNAME -c 'defaults write com.microsoft.Excel "2008Default SaveDefault Format" -int 57' su $USERNAME -c 'defaults write com.microsoft.Powerpoint "2008 Default SaveDefault SaveDefault Format" "Microsoft PowerPoint 98 Presentation"'

echo "Done."
fi

exit 0

tlarkin
Honored Contributor

Here is what I came up with, and I think I will have casper run it on
every client machine. Not all of our machines are on mobile accounts at
the moment so if it looped through all user accounts it would work. Thus far, this is what I wrote, what do you all think?

#!/bin/sh

#loop through user accounts and enable plain text for AFP

file=com.apple.AppleShareClient.plist

for file in /Users/*/Library/Preferences/*

if [[ -e $file ]]

then defaults write com.apple.AppleShareClient "afp_cleartext_allow"
?bool YES

else echo "no file found"

fi

done

exit

If any of you think of a better way I would gladly like to hear it.

Thanks,

Tom