How can I run applescript.scpt from the terminal and pass terms / variables?

I have applescript that does something on these lines:

using terms from application "Quicksilver"
    on open theseitems
        repeat with aitem in theseitems
            display dialog aitem as text
        end repeat
    end open
end using terms from

But what I would like to do is run a specific file applescript.scptthrough the terminal and pass in a variable, such as the path to the file.

osascript ~/applescript.scpt /path/to/my/file.txt

and then run Applescript with access to this parameter. In this case, he (hopefully) displays a dialog with this path,/path/to/my/file.txt

I know that I could achieve this by doing something like

osascript -e "display dialog "~/path/to/file.txt"

But the point is not to display a dialog with Applescript, but rather as to whether I can pass the variable to the script file.

+5
source share
1 answer

script on run :

on run arg
  --do whatever you want with arg
end run

, arg - . enter image description here

enter image description here

+6

All Articles