[英]Osascript to Bash Command
This is very simple. 这很简单。 Just can't get it right.
只是无法正确解决。
I am making a alfredworkflow, where I want to take a URL, then curl / wget (program doesnt matter) in terminal. 我正在做一个alfredworkflow,我想要一个URL,然后在终端中curl / wget(程序无关紧要)。 If I can do this in the background that would be excellent, but if it needs to open terminal I can live with that.
如果我可以在后台执行此操作,那将非常好,但是如果需要打开终端,我可以接受。
So far what I have: 到目前为止,我有:
tell application "Google Chrome"
set theURL to URL of active tab of window 1
end tell
tell application "Terminal"
activate
do script "echo "${theURL}
end tell
Try this: 尝试这个:
tell application "Google Chrome"
set theURL to URL of active tab of window 1
end tell
do shell script "curl --remote-name '" & theURL & "'"
The string concatenation operator in AppleScript is &
, and you don't put ${...}
around variables. AppleScript中的字符串连接运算符是
&
,并且您不要在变量周围放置${...}
。
This will run curl
in the background, there's no need to open a terminal. 这将在后台运行
curl
,无需打开终端。 The --remote-name
option tells it to write the result to a file named like the filename part of the URL. --remote-name
选项告诉它将结果写入名称类似URL的文件名部分的文件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.