Posted on 10-14-2010 06:13 AM
I have ended up with an annoyance that seemed so easy to fix.. before I tried to fix it.
I have a random group of users with a symlink sitting in their home directory where the Movies folder used to be. I am trying to script my worries away but I've run into a roadblock thanks to the fact that all my users are networked.... so there's no local directory @ login.
Since my scritping kungfu is weak I am stuck. feel like this should be doable. Any advice?
seems so easy...
rm -r ~/Movies
mkdir ~/Movies
chmod 700 ~/Movies
If I could pass the command from root to the current console user that'd do it.
any clues would be of great help.
thanks
Posted on 10-14-2010 06:27 AM
Hi,
Ive attached a script which you can put into Casper Admin, you can then use it to run any script as the logged in user,
Parameter 4 = the folder the script is in Parameter 5 = the script to run
or you could copy the following line to the script you want to use
#!/bin/sh
current_user=/usr/bin/w | grep console | awk '{print $1}'
echo $current_user
su $current_user pathtoscript/yourscript.sh
echo Done
exit 0
Criss
Criss Myers
Senior IT Analyst (Mac Services)
iPhone / iPad Developer
Apple Certified Technical Coordinator v10.5
LIS Development Team
Adelphi Building AB28
University of Central Lancashire
Preston PR1 2HE
Ex 5054
01772 895054
Posted on 10-14-2010 07:15 AM
Excellent!! thank you for the leg up.
but... always a but... I am getting a error code I do not understand given the context of your script.
I put the script I want to run at /Library/Scripts/OITScripts, set as parameter 4, and the script name set as parameter 5. the script runs, but I get the following in the policy log:
Script Exit Code:0 Script Result: /private/tmp/RunCustomScript.sh: line 5: cd: HOME not set
Done
the script I refer to is as follows:
#!/bin/sh
rm -r ~/Movies
mkdir ~/Movies
chmod 700 ~/Movies
Posted on 10-14-2010 11:45 AM
Try this?
#!/bin/bash
USER=who | grep "console" | cut -d" " -f1
rm r /Users/$USER/Movies
mkdir /Users/$USER/Movies
chown $USER:staff /Users/$USER/Movies
chmod 700 /Users/$USER/Movies
You should be able to run that from casper as a policy when a user is logged
in. So either a login hook or a self-service policy would probably be most
effective.
Bob
Posted on 10-14-2010 11:54 AM
Along the lines of what I intended to do but as a network user there is nothing at /Users to act upon.
That's why I was working with ~/ instead of an absolute path. the benefits of network users is great but it makes the simple things inordinately frustrating at times.