I'm having trouble with opening Safari from terminal. Command I tried is
/Applications/Safari/Contents/MacOS/Safari http://www.example.com
Safari opens and tries to navigate to the url:
file:///Current/Terminal/Path/Here/http:/www.example.com
I know, I could do it using open
:
open -a safari http://www.example.com
But I can't. The bigger picture is quite complicated: I'm actually trying to run the browser from command-line .NET application (which is running using mono). I use System.Process
.NET class to run the command and I have to be able to control the process (get process Id, check if it's active, kill it if necessary, etc.). Using open
command does not return correct process Id (I tried using open
with -W
switch – does not help either).
Best Answer
One solution would doing this in 2 times
tell application "Safari" to open location "http://www.google.com"
Here is a oneliner :
NB: you need to wait before running the AppleScript because Safari is not started yet. The
sleep 1
might not work in every case since it will really depend on how much time Safari will need to start.