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. 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.
This will run curl
in the background, there's no need to open a terminal. The --remote-name
option tells it to write the result to a file named like the filename part of the URL.