2
我正在處理一個Applescript,當它執行命令檢查命令的結果後,我執行它,它會提示一條消息(在AppleScript編輯器中); Expected expression but found 「error」.
。Applescript在執行shell腳本時返回「非零狀態下退出的命令」
我該如何備份並檢查命令是否與The command exited with a non-zero status.
相同,以便我可以做其他事情,如果它與錯誤消息相同?
do shell script "echo \"stats\" | nc localhost 11211" password "~password~" with administrator privileges
if error = "The command exited with a non-zero status." then
display dialog "Returned zero"
else if result = "The command exited with a non-zero status." then
display dialog "Returned zero"
else if result = "" then
do shell script "memcached -d -l 127.0.0.1 -p 11211 -m 64"
display dialog "Memcached Started"
else
do shell script "killall memcached" with administrator privileges
display dialog "Memcached Stopped"
end if
編輯:更新版本
set error to do shell script "echo \"stats\" | nc localhost 11211" password "~password~" with administrator privileges
if error = "The command exited with a non-zero status." then
do shell script "memcached -d -l 127.0.0.1 -p 11211 -m 64"
display dialog "Memcached Started"
else
do shell script "killall memcached" with administrator privileges
display dialog "Memcached Stopped"
end if