Shutdown via command script / Sudoers question
Hello MacGeniuses.
Having tried to figure out the solution for myself, I've only managed to get to a partial solution.
Primary Issue:
I want to use a desktop alias to shut down the computer. The reason is because I wish to to run another command first without having to open a terminal every time.
And I also don't want to enter a password every time.
Based on my homework, I created a text file, gave it a .command extension, did a chmod +x, and then tried to use to to run the following commands, both starting with a space to keep them out of the command history:
echo password | sudo nvram SystemAudioVolume=%80
echo password | sudo shutdown -h now
The commands work fine if and only if I've already done a sudo within terminal that session. If I haven't then I'm prompted for my password.
I even tried adding myself to the sudoers file (in the last line) but that didn't help:
Steve ALL=(ALL) NOPASSWD: /sbin/poweroff, /sbinreboot, /sbin/shutdown, /usr/sbin/nvram
Please know that when it comes to Linux-type stuff I'm just a monkey-see, monkey-do person, so if you give me good advice I may come back with a response like, "What's a power cord?" Please be as gentle as you can.
Secondary issue:
Every time I open terminal I get a list of stuff like shown below (there were several, I just cut and paste one of them). Anyone know how to stop that?
[Restored Jul 22, 2016, 20:54:32]
Last login: Fri Jul 22 20:53:18 on ttys000
Restored session: Fri Jul 22 20:53:56 EDT 2016
Steves-iMac:Desktop Steve$ chmod +x Shutdown.command
Steves-iMac:Desktop Steve$ exit
logout
Saving session...
...saving history...truncating history files...
...completed.
[Process completed]
iMac (Retina 5K, 27-inch, Late 2015), El Capitan