2011-08-16 5 views

Répondre

0

Pouvez-vous: a) Exécuter un de programme de ligne de commande Ruby b) Sauvegardez votre flux de travail Automator comme une application

Si oui, vous devriez être pouvoir exécuter la commande open, par exemple open test.app --args someArg. Vous pouvez également utiliser la commande automator, par exemple echo "someArg" | automator -i - test.app

Notez que l'intégralité du script Automator s'exécutera une fois pour chaque argument. Essayez d'utiliser 'Speak Text' comme premier élément pour vérifier cela.

Pour travailler avec tous les paramètres en une fois, vous devez en passer un seul, puis le diviser, par ex. open test.app --args "one|two|three|four" alors quelque chose comme

 
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 

Cependant, le AppleScript semble ne fonctionner que si ce n'est pas la première action. Si vous en avez besoin comme première action, ce que vous faites probablement, insérez d'abord un script Run Shell qui ne fait que passer les arguments:

 
for f 
do 
    echo “$f" 
done 
Questions connexes