So I have a script in ruby that obviously uses variables. Part of the script opens an app and runs an automator workflow. There are some variables in my ruby script that I need my workflow to use. Is this possible in anyway?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Are you able to:
a) Execute a command line program from Ruby
b) Save your Automator workflow as an application
If so, you should be able to run the
opencommand, e.g.open test.app --args someArg. Or you could use theautomatorcommand, such asecho "someArg" | automator -i - test.appNote that the entire Automator script will run once for each argument – try having ‘Speak Text’ as your first item to verify this.
To work with all the parameters in one go you need to actually pass just one and then split it up, e.g.
open test.app --args "one|two|three|four"then something likeon 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 theSplitHowever, the AppleScript only seems to work if it’s not the first action. If you need it as the first action, which you probably do, insert a Run Shell Script first that just passes on the arguments: