2

アプリケーションと.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)

まだ運がない。

4

1 に答える 1

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
于 2012-12-05T12:12:06.360 に答える