Open a url in mac with blocking terminal

Joined
May 18, 2011
Messages
2
Reaction score
0
Points
1
Hi,

I am trying to open a url in Safari through terminal in my MAC machine. I am using following command:

open -a /Applications/Safari.app Google

As soon as hit enter, this url opens in Safari but terminal doesn't block i.e. it comes out.

Then, i tried:
open -a /Applications/Safari.app/Contents/MacOS/Safari Google

same thing happens: As soon as hit enter, this url opens in Safari but terminal doesn't block i.e. it comes out.

Then i tried:
/Applications/Safari.app/Contents/MacOs/Safari Google

in this case, as soon as i hit enter, it blocks the terminal but in browser (Safari) it opens: file:///Users/Administrator/http:/google.com

How i open one url using terminal such that it opens that url properly in Safari and it blocks terminal also until i close the browser (in that case, it should come out).
 
OP
T
Joined
May 18, 2011
Messages
2
Reaction score
0
Points
1
Hi,

I am trying to open a url in Safari through terminal in my MAC machine. I am using following command:

open -a /Applications/Safari.app Google

As soon as hit enter, this url opens in Safari but terminal doesn't block i.e. it comes out.

Then, i tried:
open -a /Applications/Safari.app/Contents/MacOS/Safari Google

same thing happens: As soon as hit enter, this url opens in Safari but terminal doesn't block i.e. it comes out.

Then i tried:
/Applications/Safari.app/Contents/MacOs/Safari Google

in this case, as soon as i hit enter, it blocks the terminal but in browser (Safari) it opens: file:///Users/Administrator/http:/google.com

How i open one url using terminal such that it opens that url properly in Safari and it blocks terminal also until i close the browser (in that case, it should come out).
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
Merged threads. Please do no crosspost (post message in more than one forum).

Can you clarify what you mean by "terminal doesn't block" and "it comes out"? From what I see, you've pretty much exhausted your options there.
 
Joined
Mar 17, 2008
Messages
6,879
Reaction score
191
Points
63
Location
Tucson, AZ
Your Mac's Specs
Way... way too many specs to list.
Code:
mikeMbp:~ mike$ open -a /Applications/Safari.app "http://www.google.com"
mikeMbp:~ mike$  echo $?
0

works fine for me. Terminal's still available too, which makes sense. The command's been successfully completed, which is why it returns to a prompt (so it doesn't come out, it's done processing). Why are you looking to hang the stdin is probably a better question at this point.
 
Joined
Dec 9, 2010
Messages
844
Reaction score
49
Points
28
Location
Virginia
Your Mac's Specs
Currently 13" Late 2010 MBA, 4GB/128GB; Early 2011 13" MBP, dual core i7 2.7ghz, 4gb ram, 500gb hd
This isn't going to be solved by a simple single line command. Open is doing exactly what it's supposed to - it's a finite command, and once the app is open, it's done and returns the user to the command prompt. The other option, calling the app directly, attempts to point the user to a local file on the computer. Odds are this is going to require some combination of shell and AppleScript to call the proper URL. Maybe that's the clue - create the AppleScript to open the URL, and then call it directly.
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top