When you run scripts in Casper, they generally happen in the context of the admin account, not the logged in user. Depending on how you're running it, $HOME is likely resolving to your admin account, not the logged in account.
The Generally Accepted™ way of doing it is to run it with a policy that has a login or logout trigger and use $3 instead. The jamf binary will resolve $3 to the logging in or out user.
If it's not run at login (or logout) and is instead run at the every15 trigger you can use something like
1user=`ls -la /dev/console | cut -d " " -f 4`
and then call something like /Users/$user in your script.
so how would i use $3 to have a script run as the logged in user? All the script is doing is calling another script as the user and its being run as the admin since its being called by casper:
"sh /location/location/loginscript.sh&"
exit 0
create a launch agent it will run as the user when he/she logs in.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.my.login</string>
<key>ProgramArguments</key>
<array>
<string>/path/toyour/loginscript.sh</string>
</array>
<key>RunAtLoad</key>
<true/>
</dict>
</plist>
permissions should to be 644, file has to be owned by root:wheel lives in /Library/LaunchAgents
THanks but even though the plist file loads, the script never ends up running, any help would be appreciated