Posted on 01-14-2014 09:21 AM
trying to modify the FireFox prefs.js file in the local profile with the script below and getting the error below when run from casper. It works fine in terminal.
#!/bin/bash
user=ls -la /dev/console | cut -d " " -f 4
echo user_pref ('"network.negotiate-auth.trusted-uris", "my domain"')';' >>Users/$user/Library/Application Support/Firefox/Profiles/*.default/prefs.js
done
exit 0
Running script modify firefox whitelist.sh...
Script exit code: 2
Script result: /Library/Application Support/JAMF/tmp/modify firefox whitelist.sh: line 5: Users/sardesm/Library/Application Support/Firefox/Profiles/*.default/prefs.js: No such file or directory
/Library/Application Support/JAMF/tmp/modify firefox whitelist.sh: line 7: syntax error near unexpected token `done'
/Library/Application Support/JAMF/tmp/modify firefox whitelist.sh: line 7: `done'
Finished.
Any help would be appreciated.
Posted on 01-14-2014 09:34 AM
I'm not 100% sure but it looks like you may need a / in front of Users just after the redirect.
>>/Users
Posted on 01-14-2014 09:41 AM
+1 /Users will help a lot.
when you have been testing you likely have been at / when running the script, probably its current directory during execution through Casper is likely /var/root and there is no Users directory in there.
Posted on 01-14-2014 12:22 PM
Hey there,
I think the other responders have caught the error, and assuming that your home folders all live in /Users/, you're done.
If this works and does what you need it to do, don't mess with success. However I do have a suggestion that might be useful...
This script hardcodes the /Users/ path, and that works, but only if all of your user home folders live there. If you have a hidden user or a user with a network home, you'll run into problems.
I would suggest defining the logged in user's username, possibly using the $3 Casper Suite script parameter, then query for that account's home folder path using dscl.
Does that make sense?
Posted on 01-14-2014 12:33 PM
yeah @cOnOr posted a nice way to do that last week and how to get the consoleuser apart from $3 i would search for that.
Posted on 01-14-2014 01:27 PM
Agreed with the above. Although in most cases you won't ever see a problem, as soon as this runs against an account that isn't in /Users/ its all over. Always a good idea to get the home directory path, just to be sure.
#!/bin/bash
# When logged in as myself
user=$(ls -l /dev/console | awk '{print $3}'); echo "$user"
mike
userHome=$(dscl . read /Users/$user NFSHomeDirectory | awk '{print $NF}'); echo "$userHome"
/Users/mike
# When logged in as hidden administrator
user=$(ls -l /dev/console | awk '{print $3}'); echo "$user"
administrator
userHome=$(dscl . read /Users/$user NFSHomeDirectory | awk '{print $NF}'); echo "$userHome"
/var/administrator
Posted on 01-14-2014 07:04 PM
I will test tomorrow and let you guys know, thanks for the assist. I was thinking it was the * wildcard messing it up.
Posted on 01-14-2014 07:07 PM
Actually just modded the script and tested and it worked. Thanks for your help. Next time I know silly Mistake.