Running three shell scripts as SU in admin account

Joined
Oct 4, 2010
Messages
9
Reaction score
0
Points
1
Hello everyone!

I'm not sure if this is the right place to put this, but here goes.

I want to automate things a bit on my home network so that way I don't have to spend a lot of time doing it myself. What I want to do is simple:

1). Have the computer shutdown at 1:00 AM Sunday-Friday Saturday, I want it to shutdown at 3:00 AM

2). I want to run the Apple Updates at 1:00 AM on Saturday morning without any user intervention.

3). After the Apple Updates, I want the computer to restert, so let's say it should restart at 2:00 AM. Then, I would have the computer shutdown at say, 3:00 AM.

I've written the shell scripts, and they work; I've tested them. No problems there ... at least not that I know of. I've used CronniX to schedule the tasks to run at the designated times. The scripts are invoked, HOWEVER, they prompt for a password as they all need to be in superuser, or root mode.

I'm stuck. How do I accomplish that. I thought about modifying the root's crontab, but I can't find that. I tried modifying the sudoers file, which was disasterous (thank God for Time Machine). Any help would be appreciated.

I'm running SL 10.6.4 with the latest updates.

Thanks for your time, patience and help.
 
Joined
May 22, 2005
Messages
2,159
Reaction score
67
Points
48
Location
Closer than you think.
Your Mac's Specs
Performa 6116 2GBSCSI 8MB OS 7.5.3
Applescript can help. Create the applescript to call the shell commands like such.

do shell script "sudo ifconfig en0 down; sudo ifconfig en0 up" password "your_password" with administrator privileges

Then have cronnix run those new applescripts.
 
OP
K
Joined
Oct 4, 2010
Messages
9
Reaction score
0
Points
1
I'll try the Applescript route.

Will this happen regardless of whether or not I'm logged in?

Thanks!
 
OP
K
Joined
Oct 4, 2010
Messages
9
Reaction score
0
Points
1
Could I use launchd to accomplish what I want to do? Would that also run scripts if I'm logged out. The computers would stay awake; they just would be logged out.

Thanks!
 
Joined
May 22, 2005
Messages
2,159
Reaction score
67
Points
48
Location
Closer than you think.
Your Mac's Specs
Performa 6116 2GBSCSI 8MB OS 7.5.3
If the script you write requires no end user input it should run.

I would say stick with cron. Launchd would require more to get it to work.
 
OP
K
Joined
Oct 4, 2010
Messages
9
Reaction score
0
Points
1
The only input that the users have right now is the password, which is what I'm trying to work around. I don't want them to enter a password.

So, would I still write the Applescript, and how would I go about doing that, if that were to be the option I would choose?

Maybe I'll try editing my sudoers file again, and do that i visudo so that it can change the appropriate parameters.

Cron does seem like it would be easier than launchd. But the other thing I'm trying to achieve is that the scripts run regardless of whether or not the user is logged in.

Thanks again for your patience, and help. I'm kind of a dunce when it comes to this stuff ... even though I know it can be done.
 
Joined
May 22, 2005
Messages
2,159
Reaction score
67
Points
48
Location
Closer than you think.
Your Mac's Specs
Performa 6116 2GBSCSI 8MB OS 7.5.3
The AppleScript example I gave you has you provide the password in the script
so you don't get prompted.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top