View Single Post
hype.it

 
hype.it's Avatar
 
Member Since: Mar 27, 2004
Location: China
Posts: 738
hype.it is on a distinguished road
Mac Specs: Dual 2.2GHz powered by AMD Opteron - *Sends G5 & 8Gb Ram to scrap heap* Yeah! finally switched BACK!

hype.it is offline
AppleScript version:
They may need a little editing editing when used to shut down a remote system.

Shutdown:
Code:
//begin script

tell application "Finder"
    shutdown
end tell

//end script
Restart:
Code:
//begin script

tell application "Finder"
    restart
end tell

//end script


In Mac OSX
Execute in Terminal, type carefully.

Shutdown:
Code:
 sudo osascript -e 'tell application "Finder" to shut down'
Restart:
Code:
sudo osascript -e 'tell application "Finder" to restart'

Info:
If your user isn't the currently logged in user, you might get some errors in the command line, but it will work.

"sudo" might not be required.

If there is an open application with unsaved changes, the restart will time out. This is the intended behaviour. You could try to use applescript to save and exit that application (if said application is scriptable).

Note: If the remote machine absolutely positively must be restarted, and you don't want to lose any unsaved changes (and the apps aren't scriptable), you'll have to use something like Timbuktu or OSXvnc to connect to the GUI on the remote Mac. Once you've taken that effort, though, you might as well just choose Restart in the GUI as well!
QUOTE Thanks