For example... Let's say I wanted to be able to shut down my computer via a terminal command. Given that ^⌥⌘ + eject will shut down the computer, would it be possible to somehow enter this command into terminal however, not with the keyboard shortcut, but by typing something (My question is what is this something?)?
sudo shutdown -h now
sudo shutdown -r now
Offhand the only thing that comes to mind is using the osascript command to run some AppleScript code, which can execute key events. This page has some examples of using AppleScript to issue key events.
To shutdown from Terminal, enter
Code:sudo shutdown -h now
To reboot from Terminal, enter
Code:sudo shutdown -r now
I appreciate your contribution to the discussion however, I'm looking for a terminal command which doesn't prompt a password.
echo 'yourpasswordhere' | sudo -S shutdown -r now