Running Safari from the command line adds current directory to the URL

5

1

I am trying to run the Safari browser (on Mac OS 10.4) from the command line, as follows:

/Applications/Safari.app/Contents/MacOS/Safari http://localhost/dev/myfile.html

However, Safari starts up and tries to access

file:///Users/charlesanderson/scripts/http://localhost/dev/myfile.html

/Users/charlesanderson/scripts happens to be my current directory.

Can someone explain why Safari does this? Firefox is much better behaved?

Charles Anderson

Posted 2010-04-22T16:58:47.143

Reputation: 197

Answers

12

Starting Safari with arguments isn't supported or documented, AFAIK.

It's interpreting the first argument as a path (you'll notice that if you begin it with a /, it doesn't prepend the working directory).

If you just want Safari to navigate to a URL, use open:

open -a Safari <url>

s4y

Posted 2010-04-22T16:58:47.143

Reputation: 3 469

6

How about

open -a Safari URL

Hai Vu

Posted 2010-04-22T16:58:47.143

Reputation: 4 824

0

Apparently open also handles URI protocols directly:

open http://google.com
# or
open 'http://google.com'

fregante

Posted 2010-04-22T16:58:47.143

Reputation: 395