2011-08-16 10 views

答えて

0

あなたはすることができます: A)ルビー Bからのコマンドラインプログラムを実行します)その場合はアプリケーション

としてあなたのAutomatorワークフローを保存し、あなたがする必要がありますopenコマンドを実行することができます。 open test.app --args someArg。または、コマンド(echo "someArg" | automator -i - test.app

など)を使用することもできます。Automatorスクリプト全体が引数ごとに1回実行されることに注意してください。

1つのパラメータですべてのパラメータを処理するには、実際には1つだけ渡して分割する必要があります。 open test.app --args "one|two|three|four"その後、

 
on run input 
    set myArray to my theSplit(input as string, "|") 
    set a to item 1 of myArray 
    set b to item 2 of myArray 
    set c to item 3 of myArray 
    set d to item 4 of myArray 
    display dialog "c is " & c 

     --do stuff 
    return str 
end run 

on theSplit(theString, theDelimiter) 
    -- save delimiters to restore old settings 
    set oldDelimiters to AppleScript's text item delimiters 
    -- set delimiters to delimiter to be used 
    set AppleScript's text item delimiters to theDelimiter 
    -- create the array 
    --set theArray to every text item of theString 
    set theArray to text items of theString 
    --display dialog theArray as string 
    -- restore the old setting 
    set AppleScript's text item delimiters to oldDelimiters 
    -- return the result 
    return theArray 
end theSplit 

のようなものは、しかし、AppleScriptのは、それが最初のアクションでなければ動作しているようです。おそらく最初に実行する必要がある場合は、最初に引数を渡すだけのRun Shell Scriptを挿入します。

 
for f 
do 
    echo “$f" 
done 
-1

はい、パラメータをルビスクリプトに渡すことは可能です。ここですてきなチュートリアルでは、次のとおりです。

http://ruby.about.com/od/rubyfeatures/a/argv.htm

+0

ご回答ありがとうございます。私の質問は分かりません。私はルビースクリプトから私のオートマチックワークフローにパラメータを渡したいと思います。 – thisiscrazy4

関連する問題