Results 1 to 7 of 7
  1. #1


    Member Since
    Oct 04, 2010
    Posts
    9
    Running three shell scripts as SU in admin account
    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.

  2. #2

    MacsWork's Avatar
    Member Since
    May 22, 2005
    Location
    Closer than you think.
    Posts
    2,159
    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.

  3. #3


    Member Since
    Oct 04, 2010
    Posts
    9
    I'll try the Applescript route.

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

    Thanks!

  4. #4


    Member Since
    Oct 04, 2010
    Posts
    9
    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!

  5. #5

    MacsWork's Avatar
    Member Since
    May 22, 2005
    Location
    Closer than you think.
    Posts
    2,159
    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.

  6. #6


    Member Since
    Oct 04, 2010
    Posts
    9
    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.

  7. #7

    MacsWork's Avatar
    Member Since
    May 22, 2005
    Location
    Closer than you think.
    Posts
    2,159
    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.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Learning the Command Line - Shell Scripts
    By vansmith in forum News and Community Announcements
    Replies: 9
    Last Post: 04-14-2014, 04:27 AM
  2. Local admin account, system admin account, no desktop
    By dphilly53 in forum OS X - Operating System
    Replies: 0
    Last Post: 08-17-2010, 09:27 AM
  3. Launching Shell Scripts using the mouse
    By johncpvt in forum OS X - Apps and Games
    Replies: 0
    Last Post: 07-10-2008, 02:18 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •