我有一个应用程序和一个.sh
文件。我需要一个苹果脚本,双击时,设置该.sh
文件的权限并运行它。
以下是我的代码:
set app_directory to POSIX path of ((container of (path to me)) as text)
tell application "Terminal" to do shell script "chmod 777 " & app_directory & " start.sh"
tell application "Terminal" to do shell script app_direcory & "start.sh"
但我得到以下错误:
错误“无法创建别名容器”Macintosh HD:用户:santhosh:桌面:EPPFN ver1:条形码Application_mac:test_app.app:\“到类型文本。”来自别名容器的数字-1700“Macintosh HD:用户:santhosh:桌面:EPPFN ver1:条形码Application_mac:test_app.app:”到文本
如何设置当前路径,然后使用相对路径运行脚本。
编辑: 我将代码修改为:
set x to POSIX file ((POSIX path of (path to me)) & "/..") as text
set thescript to ("chmod 777 " & x & "start.sh") as text
tell application "Terminal" to do shell script (thescript)
仍然没有运气。
答案 0 :(得分:0)
尝试:
tell application "System Events" to set app_directory to POSIX path of (container of (path to me))
set thescript to ("chmod 777 " & quoted form of (app_directory & "/start.sh"))
do shell script thescript