MacOS – Any way to open a URL in a script without having it open in a browser

applescriptautomationcommand linemacosscript

The situation: My mobile carrier offers for free to send SMS notifications by following a URL.

What I'd want: Include these URLs in various scripts to get notifications when I'm away from keyboard.

The problem: I can't find a way to open the URL silently (that is without opening it in a browser), the simplest thing:

do shell script "open https://myurl"

opens a tab and brings my browser to the front, so I'd have to close the tabs either manually or with some other lines in the script.

Is there's a more elegant way to do as if I had followed the link without showing it in a browser?

Best Answer

For sure there are dozens of tools to do this.

  • python scripts
  • ruby scripts
  • swift scripts
  • javascript scripts
  • shell scripts

I’d start with bash and shell, but you could do this in dozens of ways. Javascript and bash are all easy to call from AppleScript as well if you want to start there. The curl command ships with all macOS so let’s start there. Open the terminal app and type:

curl https://myurl

Once you get the basics of calling, you can determine if you need authentication or to post / get to an API to trigger the actions you need, but all of the above scripts will not open a browser and will retrieve / hit the web site with a real request that can make things happen.