我有一个应用程序和一个.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:Users:santhosh:Desktop:EPPFN ver1:Barcode Application_mac:test_app.app:\" 输入文本。” 编号 -1700 从别名“Macintosh HD:Users:santhosh:Desktop:EPPFN ver1:Barcode 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)
仍然没有运气。