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