matedwards
asked on
run login scripts as root
I have 2 login scripts. I need script1 to run if user1 logs in and script 2 to run if user2 logs in.
I believe I need to create a .plist file in the ~/Library/Launchagents folders of each user calling their respective scripts. Is this true.?
Also, the commands within the script have to be run as root.
how can user1 and user2 run the scripts as root..?
Many thanks in advance..
Mat
I believe I need to create a .plist file in the ~/Library/Launchagents folders of each user calling their respective scripts. Is this true.?
Also, the commands within the script have to be run as root.
how can user1 and user2 run the scripts as root..?
Many thanks in advance..
Mat
You are correct - you want to use Launchagent. I'm at work with an older Mac (10.4), so I can't test/show you how to do this until this evening. Hopefully another expert can show you how to do this sooner.
Can you explain what root part of script will do? Maybe that can be done without root privileges.
Normally "man visudo" explains how to run commands and what to type in visudo
Normally "man visudo" explains how to run commands and what to type in visudo
ASKER
Apolgies for the lateness..
I need the scripts to move some files out of the System folder disabling Spell Check in TextEdit. The plist files in Launchagents initiate the scripts but I keep getting a Permssion Denied error and the files aren't moved. I have added this line in the visudo file
user1 ALL=(ALL) NOPSSWD:ALL or
but I'm still getting the Permission Denied error..
many thanks for the help..
Mat
I need the scripts to move some files out of the System folder disabling Spell Check in TextEdit. The plist files in Launchagents initiate the scripts but I keep getting a Permssion Denied error and the files aren't moved. I have added this line in the visudo file
user1 ALL=(ALL) NOPSSWD:ALL or
but I'm still getting the Permission Denied error..
many thanks for the help..
Mat
Not really
user1 ALL=(ALL) NOPSSWD:ALL or
Should be
user1 ALL=(ALL) NOPASSWD: ALL
user1 ALL=(ALL) NOPSSWD:ALL or
Should be
user1 ALL=(ALL) NOPASSWD: ALL
ASKER
thanks gheist.. tried that.. no luck.. also tried..
user1 ALL=(ALL) NOPASSWD: /path/to/script
thanks again
user1 ALL=(ALL) NOPASSWD: /path/to/script
thanks again
Run the script via bash -x
sudo should show some error if command line is one-off
Normally you override system preference with editing plist under same name in users preference directory, not deleting the system files.
sudo should show some error if command line is one-off
Normally you override system preference with editing plist under same name in users preference directory, not deleting the system files.
ASKER
The script runs with no problems from the bash shell.. for example ./script
It only fails when run at login by the Launchagent.
regards
Mat
It only fails when run at login by the Launchagent.
regards
Mat
Do you read what I wrote here? You can override system plists per-user. No unix involved.
ASKER
If User1 logs in Script1 moves three files out of /System to disable SpellCheck in TextEdit..
/System/Library/Coreservic es/CarbonS pellChecke r.bundle
/System/Library/Services/A pplespell. Service
/System/Library/Spelling
If User2 logs in Script2 moves them back to enable Spellcheck in TextEdit
How can this be done in system plist per-user..?
/System/Library/Coreservic
/System/Library/Services/A
/System/Library/Spelling
If User2 logs in Script2 moves them back to enable Spellcheck in TextEdit
How can this be done in system plist per-user..?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
No solution
http://stackoverflow.com/questions/97137/how-do-you-run-a-script-on-login-in-nix