2016-04-05 4 views
0

私は、ファイルを選択するためのオートメーションサービスを作成して、シェルスクリプトを使用して選択したファイルをアップロードします。私は自分の変数を働かせるようには見えない。私はAutomatorとAppleScriptをあまり使い慣れていませんし、それらについてよく知らないので、初心者の間違いかもしれません。AppleScriptにオートマトン変数を含めるには?

これを行うより良い方法がある場合は、お知らせください。

ここに私のAppleScriptコードは次のとおりです。

on run {input01, input02, path} 
    set input01 to "scp -i /Users/jeffArries/Desktop/jeffarries.pem -rp /Users/jeffArries/Desktop/Website_Testing_Folder/" 
    set input02 to "[email protected]:/var/www/html" 
    do shell script "{input01} & {Path} & {input02}" 
end run 

そして、Automatorののスクリーンショット:enter image description here

答えて

3

あなたはそれをあなたの方法をする必要はありません。 Automator Serviceを作成すると、選択した項目のパスが自動的にサービスに渡されます。 「ファイル&フォルダ」を選択するだけです(スクリーンショットでは「入力なし」と表示されます)。

その後、Automator変数を使用する必要はありません。すべてのパスは、inputパラメータ内のリストとして検出できます。

その後、普通の文字列のようにシェルコマンドをビルドし、do shell scriptで実行する必要があります。

私はあなたのための有益なコメントでそれを埋め、始めるためにこれを試してみてください:

on run {input, parameters} 

    -- setting your AppleScript variables 
    set input01 to "scp -i /Users/jeffArries/Desktop/jeffarries.pem -rp /Users/jeffArries/Desktop/Website_Testing_Folder/" 
    set input02 to "[email protected]:/var/www/html" 

    -- loop through selected finder items 
    repeat with aFinderItem in input 
     -- check if the aFinderItem is a file and not anything else 
     tell application "System Events" to set theItemIsAFile to ((get class of item (aFinderItem as text)) = file) 
     if theItemIsAFile then 
      -- store the POSIX path of the file 
      set theItemsPosixPath to POSIX path of aFinderItem 
      -- build the shell scp command 
      set myShellCommand to input01 & " " & quoted form of theItemsPosixPath & " " & input02 
      -- exceute the command 
      do shell script myShellCommand 
     end if 
    end repeat 
    return input 
end run 

は 、マイケル/ハンブルク

をお楽しみください。
関連する問題