Terminal command to open Safari
If Safari is your default browser, you just use
open <url>
for example:
open http://www.google.com
You can also use this command to open any file with its registered application.
There are several ways to do this. The simplest way would be to use /usr/bin/open
:
/usr/bin/open http://stackoverflow.com/
will open the URL in the standard browser or
/usr/bin/open -a Safari http://stackoverflow.com/
will explicitly use Safari.
You can also use AppleScript via the javax.script
API (JSR 223) but I do not know the syntax right now.