Shell 在错误条件下强制退出AppleScript应用程序

Shell 在错误条件下强制退出AppleScript应用程序,shell,applescript,Shell,Applescript,当我关闭网络时,它会给我一个错误,说“无法解析主机”,并且它不会退出应用程序,而是留在后台 当无法连接到服务器或任何其他命令以强制退出或禁止并继续时,是否有适当的方法退出应用程序 结束正在运行的脚本的正确方法是使用return: try set logindetails to (do shell script "curl google.com") on error display dialog "Unable to connect." quit e

当我关闭网络时,它会给我一个错误,说“无法解析主机”,并且它不会退出应用程序,而是留在后台


当无法连接到服务器或任何其他命令以强制退出或禁止并继续时,是否有适当的方法退出应用程序

结束正在运行的脚本的正确方法是使用
return

try
    set logindetails to (do shell script "curl google.com")
    on error
        display dialog "Unable to connect."
        quit
end try

请参阅。

我使用
错误号-128

try
  set logindetails to (do shell script "curl google.com")
on error
  display dialog "Unable to connect."
  return
end try

我确实使用了return,但应用程序没有退出。它仍保留在背景中。当我的应用程序持续在bckgrd中运行时,我尝试了on idle,也尝试了不使用on idle。它确实有效。它基本上不会退出,因为它会查找未解析的主机,并且永远不会完成需要退出的任务。还有其他解决方案吗?
curl
实际返回了吗?尝试将
--max time 15
添加到
curl
命令中,以在15秒后超时连接。
curl
此时正在等待响应,应用程序在此处卡住。然后我不得不被迫辞职。当与服务器的连接中断时,我想在此时继续。我尝试了
--最大时间15
,但在成功连接后,当连接中断且此应用程序在后台以
处于空闲状态运行时,
。您可能可以缓解此问题,但将
set
命令包装在带有超时的
块中–但是,如果你发布了你的实际代码(我猜你并不是在向谷歌查询登录凭证),那么找到解决方案就会容易得多;请把密码之类的敏感数据弄糊涂。当我使用
-max-time
interval时,它对我很有效
curl--max time 5-d\“username=“&loginusername&“\”&domain&“/playlists.php
”。是的,我没有使用谷歌来获取数据。这行代码是真正的代码。谢谢。这个代码要做什么?我希望避免出现错误对话框。不过我会尝试一下。与调用
return
完全相同–实际上,这是在调用
return
:)时脚本返回的错误代码。
try
  set logindetails to (do shell script "curl google.com")
on error
  display dialog "Unable to connect."
  error number -128
end try