hello,
I am trying to shutdown my Imac through a shell command. I first tried:
ssh -i /config/ssh_keys/id_rsa [email protected] "shutdown -h now"
I was getting the message “Not a super user”.
Of course it didn’t work as I had to use sudo.
So I gave up this method as I don’t want to login as root … (and you can’t pass root password over command line)
Then I found out that I can call osacript from command line but I am having hard time with quotes.
If I login to Imac and then run:
osascript -e 'tell app "System Events" to shut down'
It works! Imac shuts down without asking for a password! Bingo!
But when I try to run it from command line it doesn’t!
ssh -i /config/ssh_keys/id_rsa [email protected] osascript -e 'tell app "System Events" to shut down'
Any help will be very appreciated!