【发布时间】:2012-01-29 17:28:27
【问题描述】:
我们有一个由 9 台 Mac 组成的网络,我想一次性关闭它们。 现在我正在使用这个 AppleScript,但正如你所看到的,它使用 SSH 来一一关闭计算机。如果其中一个已经关闭,脚本将冻结。 有什么方法可以让我一次性关闭所有这些 Mac?
set finalIP to 100
repeat until finalIP is 109
tell application "Terminal"
activate
set success to 0
do script "echo Rebooting.."
do script "ssh -l username 192.168.1." & finalIP in front window
delay 1
repeat until success = 1
if last word of (contents of front window as text) = "no" then
do script "yes" in front window
delay 1
else if last word of (contents of front window as text) = "password" then
do script "password" in front window
set success to 1
do script "echo About to reboot.." in front window
else
delay 1
end if
end repeat
do script "sudo reboot" in front window
repeat until last word of (contents of front window as text) = "password"
delay 1
end repeat
do script "password" in front window
close front window
end tell
set finalIP to finalIP + 1
delay 1
end repeat
tell application "Terminal" to quit
【问题讨论】:
标签: macos shell applescript