【发布时间】:2012-12-05 11:54:09
【问题描述】:
我有一个应用程序和一个.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:\" 转换为文本。”从别名“Macintosh HD:Users:santhosh:Desktop:EPPFN ver1:Barcode Application_mac:test_app.app:”的容器编号 -1700 到文本
如何设置当前路径,然后使用相对路径运行脚本。
编辑: 我将代码修改为:
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)
还是没有运气。
【问题讨论】:
标签: macos applescript