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.
Thanks!
Nakul
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.
Thanks!
Nakul
run(`open -a Safari http://www.google.com/`)
… 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 = https://www.youtube.com/watch?v=venyMc86h8U
a = run(`open -a Safari `+ link)
link = "https://www.youtube.com/watch?v=venyMc86h8U"
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
Stacktrace:
[1] top-level scope at none:0
julia> "a" * "b"
"ab"
Though this type of syntax doesn’t work with Cmd
and String
, so you should use interpolation as suggested.
Thank you for these tips. I have a related question. I tried mutating the script to open a specific file of my computer in SublimeText. The substitution I did does not work. When I don’t include the pathname, SublimeText opens but it does not open a specific file.
Thanks,
Nakul
#runjl
#runjl
a = run(`open -a /Applications/Sublime\ Text.app/Contents/SharedSupport/bin/subl /Users/nakultiruviluamala/Library/Mobile Documents/com~apple~CloudDocs/PureData Cloud/XML/musicxmlextract.jl`)