我怎样才能从终端发起applescript.scpt文件,并通过术语/变量? [英] How can I launch an applescript.scpt file from the terminal and pass terms / variables?

查看:398
本文介绍了我怎样才能从终端发起applescript.scpt文件,并通过术语/变量?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有做东西沿着这些路线的AppleScript:

I have an applescript that does something along 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

但我想要做的就是能够开始运行通过终端特定的 applescript.scpt 文件,并传递一个变量,就像一个路径文件中。

But what I'd like to do is be able to start running a particular applescript.scpt file via the Terminal and pass in a variable, like a path to a file.

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

,然后让AppleScript的访问到该参数运行。在这种情况下,它(希望)与路径显示一个对话框, /path/to/my/file.txt

我知道我可以做类似

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

但问题是不显示与AppleScript的对话,而是更多的是知道我是否能够通过一个变量中的脚本文件。

But the point is not to display a dialog with Applescript, rather it's more about knowing if I would be able to pass a variable in to a script file.

推荐答案

在您在传递参数的脚本上运行是这样的:

In the script you pass in the arguments with the on run like this :

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

如果指定了多个参数的 ARG 变量列表。

If more than one argument is specified the arg variable is a list.

这篇关于我怎样才能从终端发起applescript.scpt文件,并通过术语/变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆