5

I'm trying to open Safari (on OS X 10.8) from the terminal by executing the following:

open -a /Applications/Safari --args "http://www.example.com"

Safari opens and tries to navigate to the url:

file:///http:/www.example.com

Is there a way to get Safari to open up the browser at the specified url?

Note: I can't do open http://www.example.com because I can't be guaranteed that the Safari is the default browser. (And before I'm asked why I'm not using the default browser - I'm doing browser specific test automation.)

1 Answer 1

10

It would seem the answer is:

open -a safari http://www.example.com

According to the man page for open(1), open -a <applicationName file> opens a given file with a given application. Therefore, this seems like the most appropriate syntax.

This forum thread explain more.

1
  • The correct syntax would be open -a Safari --args example.com, however Safari doesn't seem to have any documented example for opening a URL per discussions.apple.com/thread/…
    – tresf
    Commented Jun 7, 2023 at 6:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .