New To Mac-Forums?

Welcome to our community! Join the discussion today by registering your FREE account. If you have any problems with the registration process, please contact us!

Get your questions answered by community gurus Advice and insight from world-class Apple enthusiasts Exclusive access to members-only contests, giveaways and deals

Join today!

 
Start a Discussion
 

Mac-Forums Brief

Subscribe to Mac-Forums Brief to receive special offers from Mac-Forums partners and sponsors

Join the conversation RSS
OS X - Operating System General OS operation information and support

Running three shell scripts as SU in admin account


Post Reply New Thread Subscribe

 
Thread Tools
kc0mmy

 
Member Since: Oct 04, 2010
Posts: 9
kc0mmy is on a distinguished road

kc0mmy is offline
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.
QUOTE Thanks
MacsWork

 
MacsWork's Avatar
 
Member Since: May 22, 2005
Location: Closer than you think.
Posts: 2,145
MacsWork is just really niceMacsWork is just really niceMacsWork is just really niceMacsWork is just really niceMacsWork is just really nice
Mac Specs: Performa 6116 2GBSCSI 8MB OS 7.5.3

MacsWork is offline
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.
QUOTE Thanks
kc0mmy

 
Member Since: Oct 04, 2010
Posts: 9
kc0mmy is on a distinguished road

kc0mmy is offline
I'll try the Applescript route.

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

Thanks!
QUOTE Thanks
kc0mmy

 
Member Since: Oct 04, 2010
Posts: 9
kc0mmy is on a distinguished road

kc0mmy is offline
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!
QUOTE Thanks
MacsWork

 
MacsWork's Avatar
 
Member Since: May 22, 2005
Location: Closer than you think.
Posts: 2,145
MacsWork is just really niceMacsWork is just really niceMacsWork is just really niceMacsWork is just really niceMacsWork is just really nice
Mac Specs: Performa 6116 2GBSCSI 8MB OS 7.5.3

MacsWork is offline
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.
QUOTE Thanks
kc0mmy

 
Member Since: Oct 04, 2010
Posts: 9
kc0mmy is on a distinguished road

kc0mmy is offline
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.
QUOTE Thanks
MacsWork

 
MacsWork's Avatar
 
Member Since: May 22, 2005
Location: Closer than you think.
Posts: 2,145
MacsWork is just really niceMacsWork is just really niceMacsWork is just really niceMacsWork is just really niceMacsWork is just really nice
Mac Specs: Performa 6116 2GBSCSI 8MB OS 7.5.3

MacsWork is offline
The AppleScript example I gave you has you provide the password in the script
so you don't get prompted.
QUOTE Thanks

Post Reply New Thread Subscribe


« Keychain doesn't update stored domain password | Finder not working »
Thread Tools

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread
Thread Starter
Forum
Replies
Last Post
Creating new Admin account via terminal Gotsteve2006 OS X - Operating System 1 09-17-2008 08:34 AM
Launching Shell Scripts using the mouse johncpvt OS X - Apps and Games 0 07-10-2008 02:18 PM
Shell scripts run slow on my Macs brettgrant99 OS X - Development and Darwin 3 06-22-2006 09:58 AM
second admin account? euangel OS X - Operating System 0 11-24-2003 11:42 PM

All times are GMT -4. The time now is 02:38 AM.

Powered by vBulletin
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
X

Welcome to Mac-Forums.com

Create your username to jump into the discussion!

New members like you have made this community the ultimate source for your Mac since 2003!


(4 digit year)

Already a member?