cwd*_*cwd 5 macos terminal command-line applescript
我有一个苹果脚本可以做这些事情:
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
Run Code Online (Sandbox Code Playgroud)
但我想做的是能够applescript.scpt通过终端开始运行特定文件并传入变量,如文件路径.
osascript ~/applescript.scpt /path/to/my/file.txt
Run Code Online (Sandbox Code Playgroud)
然后让Applescript运行并访问该参数.在这种情况下,它(希望)会显示该路径的对话框,/path/to/my/file.txt
我知道我可以做类似的事情
osascript -e "display dialog "~/path/to/file.txt"
Run Code Online (Sandbox Code Playgroud)
但关键是不要显示Applescript的对话框,而是更多地了解我是否能够将变量传递给脚本文件.
在脚本中,您使用以下命令传递参数on run:
on run arg
--do whatever you want with arg
end run
Run Code Online (Sandbox Code Playgroud)
如果指定了多个参数,则该arg变量是一个列表.


| 归档时间: |
|
| 查看次数: |
10380 次 |
| 最近记录: |