Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

krayziekray

macrumors 6502
Original poster
Sep 24, 2008
333
0
127.0.0.1
So, I want to be able to turn off my Mac using Terminal without it asking for a password.

At the moment when i type:

sudo shutdown -h now

I get prompted for a password.

I need to add this to a Perl script that I'm writing for myself and need to know if there is anyway i can accomplish shutting down the Mac without having to provide my Password.

Thanks in advance guys.

:apple: KrayzieKray :apple:
 
Write your script, and change it to setuid to root. Note that anyone with access to the script will be able to shut it down.

Code:
chmod 4755 <script_name>
 
Write your script, and change it to setuid to root. Note that anyone with access to the script will be able to shut it down.

Code:
chmod 4755 <script_name>

Thanks belvdr for the quick response ... what if this Perl script was to be added into the Automator app (Run Shell Script option). Would there be any way to do it in there? As i cant change the permisson of the script in there.
 
That I don't know, as I have no experience with Automator. Maybe if you created the perl script, made it setuid root, and had automator call the perl script.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.