执行shell脚本后退出applescript应用程序
发布时间:2020-12-15 21:07:51 所属栏目:安全 来源:网络整理
导读:我想知道AppleScript应用程序是否可以运行 shell脚本,然后在 shell脚本执行完成之前退出.在运行服务器一段时间时,这将非常有用.而不是需要Applecript在后台持续运行,有没有办法独立运行一个函数? set server_name to text returned of (display dialog "Cho
我想知道AppleScript应用程序是否可以运行
shell脚本,然后在
shell脚本执行完成之前退出.在运行服务器一段时间时,这将非常有用.而不是需要Applecript在后台持续运行,有没有办法独立运行一个函数?
set server_name to text returned of (display dialog "Choose server." default answer "") set success to do shell script "if [ -f "/Users/jessefrohlich/Documents/Minecraft/" & server_name & "/minecraft_server.jar" ]; then echo 1; else echo 0; fi" if success is equal to "1" then do shell script "cd /Users/jessefrohlich/Documents/Minecraft/" & server_name & " java -Xmx1024M -Xms1024M -jar minecraft_server.jar" else display dialog "Sorry,the file you chose is invalid." end if 当上述内容作为应用程序运行时,它将正确启动服务器.但是,应用程序runScript.app将继续运行.即使强制退出AppleScript,服务器也会继续运行.一旦服务器启动,有没有办法让它自动退出? 谢谢 解决方法
试试这个.祝好运.
-- "> /dev/null" redirects standout out to nowhere land -- - you can use some other file path if you want to capture its output -- "2>&1" redirects standard error to the same place as standard out -- - 2 stands for standard error -- - 1 stands for standard out -- - > is the redirect symbol -- - & changes redirect's output from a file to a file descriptor (in this case standard out) -- & the trailing & sends the process to the background do shell script "cd /Users/jessefrohlich/Documents/Minecraft/" & server_name & " java -Xmx1024M -Xms1024M -jar minecraft_server.jar > /dev/null 2>&1 &" (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |