Terminal team to open Safari

Is there a way to open a new Safari tab with a given URL using a terminal command? Im only interested in having it work on OSX at this point. If someone knows how to do this, let me know, since I could not find the answer by browsing the web.I want to use this command to open a new tab from a java application. Thanks!

+4
source share
2 answers

If Safari is the default browser, you just use

open <url> 

eg:

 open http://www.google.com 

You can also use this command to open any file with its registered application.

+11
source

There are several ways to do this. The easiest way is to use /usr/bin/open :

 /usr/bin/open http://stackoverflow.com/ 

will open the url in a standard browser or

 /usr/bin/open -a Safari http://stackoverflow.com/ 

will use Safari explicitly.

You can also use AppleScript through the javax.script API (JSR 223), but I don't know the syntax right now.

+5
source

All Articles