Running terminal script mac osx to open web browser



Hi guys,
I am trying to have a shell command within a julia script. For instance, I am trying to open safari to a specific page.

Any help would be greatly appreciated.


run(`open -a Safari`)

… supposedly you’re running macOS


Thanks, that works great!


I am attempting to have a variable name for the link so that I can alter or push a start-time flag to the end of a youtube link.

This is what I have but it’s not working.

link =

a = run(`open -a Safari `+ link)

link = ""

a = run(`open -a Safari $link`)


@favba’s solution is probably the best one, but a couple of other things to note. First - your link = http... code throws an error because it’s not parsed. Note the quotes around the link in favba’s solution - that makes it a string.

Another thing, you might be familiar with python syntax for string concatenation, where eg "a" + "b" == "ab", but in julia this is done with *

julia> "a" + "b"
ERROR: MethodError: no method matching +(::String, ::String)
Closest candidates are:
  +(::Any, ::Any, ::Any, ::Any...) at operators.jl:502
 [1] top-level scope at none:0

julia> "a" * "b"

Though this type of syntax doesn’t work with Cmd and String, so you should use interpolation as suggested.