2009-08-06 31 views
2

起動スクリプト内でAppleScriptを実行しようとしていますが、なんらかの理由で起動しません。それは私のコンピュータである可能性がありますが、それ以外の何かが間違っているかもしれないと私は考えています。誰かがこの投稿を見てコメントすることができたら、本当にありがとう!PLISTが起動していません

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 
<plist version="1.0"> 
<dict> 
<key>Label</key> 
<string>com.pf.Testing</string> 
<key>ProgramArguments</key> 
<array> 
<string>/usr/bin/osascript</string> 
<string>-e</string> 
<string>'tell application "Finder"' -e 'set didQuit to (path to home folder as string) &amp; ".myApp"' -e 'if (exists file didQuit) then' -e 'tell application "TestApp"' -e 'activate' -e 'end tell' -e 'end if' -e 'end tell'</string> 
</array> 
<key>StartInterval</key> 
<integer>20</integer> 
<key>RunAtLoad</key> 
<true/> 
</dict> 
</plist> 

ありがとうございました!

LATEST PLIST:

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"> 
<plist version="1.0"> 
<dict> 
<key>Label</key> 
<string>com.pf.Testing</string> 
<key>ProgramArguments</key> 
<array> 
<string>/usr/bin/osascript</string> 
<string>-e</string> 
<string>'tell application "Finder"'</string> 
<string>-e</string> 
<string>'set didQuit to (path to home folder as string) &amp; ".myApp"'</string> 
<string>-e</string> 
<string>'if (exists file didQuit) then'</string> 
<string>-e</string> 
<string>'tell application "TestApp"'</string> 
<string>-e</string> 
<string>'activate'</string> 
<string>-e</string> 
<string>'end tell'</string> 
<string>-e</string> 
<string>'end if'</string> 
<string>-e</string> 
<string>'end tell'</string> 
</array> 
<key>StandardErrorPath</key> 
<string>/Users/pf/Desktop/Problem.log</string> 
<key>StartInterval</key> 
<integer>20</integer> 
<key>RunAtLoad</key> 
<true/> 
</dict> 
</plist> 

答えて

1

可能性の高い問題は、launchdのがログインしているユーザーのGUIコンテキストであなたのAppleScriptを実行していないので、AppleScriptのがファインダーに話すことができないということです。

plistがLaunchAgentとしてインストールされており、LaunchDaemonではインストールされていないことを確認してください(plistは/ライブラリ/ LauchAgentsまたは〜/ Library/LaunchAgentsにあります)。

てみGUIコンテキストで実行するスクリプトを作るために、PLISTに以下を追加:

<key>LimitLoadToSessionType</key> 
<string>Aqua</string> 

これは上記のみ10.5とで確実に動作することに注意してください。ユーザーごとのLaunchAgentを10.4で正しく動作させることができませんでした。

+0

こんにちはニック: お返事ありがとうございます。残念ながら、LimitLoadToSessionTypeコードを使用してパスにファイルが存在するかどうかを再確認した後も、それはまだ実行されません。本当に奇妙です。特にTerminalで同じコードを実行するとうまくいきます。何か考えていますか? – PF1

+1

もう1つのアイデア:引数としてAppleScriptコマンドを渡すのではなく、別のスクリプトファイルに入れて、そのパスをosascriptに渡してみてください。 –

1

最後の引数を別々の引数に分割する必要があると思います。それぞれの引数(-eとAppleScriptの個々の行)は別の<string />要素に入れる必要があります。その、またはニックはちょうど

で、スクリプト全体で.applescriptファイルに渡し言うような問題は、あなたのコマンドがあると解釈されることを次のいずれかです。あなたは何を意味していない

/usr/bin/osascript -e '\'tell application "Finder"\' -e \'set didQuit to (path to home folder as string) & ".myApp"\' -e \'if (exists file didQuit) then\' -e \'tell application "TestApp"\' -e \'activate\' -e \'end tell\' -e \'end if\' -e \'end tell\'' 

+0

こんにちはGraham:私はあなたが提案したことをしましたが、問題を記録するためにStandardErrorPathを使用すると次のエラーが発生します。0:1:構文エラー:未知のトークンはここには行かない。 (-2740) – PF1

+0

スクリプトエディタでまったく同じスクリプトを実行すると、エラーがどこにあるかがわかりますか? –

+0

いいえ、スクリプトエディタの唯一の違いは、AppleScriptドキュメントとして書式設定したことだけです。これは正常に動作します。そして、同じコードがターミナルでうまく動作し、エラーは発生しません。そのコードはあなたのために機能しますか? – PF1

関連する問題