In Python, you can do this:
import webbrowser webbrowser.open_new("http://example.com/")
It will open the passed in url in the default browser
Is there a ruby equivalent?
First, install the Launchy gem:
$ gem install launchy
Then, you can run this:
require 'launchy' Launchy.open("http://stackoverflow.com")
This should work on most platforms:
link = "Insert desired link location here" if RbConfig::CONFIG['host_os'] =~ /mswin|mingw|cygwin/ system "start #{link}" elsif RbConfig::CONFIG['host_os'] =~ /darwin/ system "open #{link}" elsif RbConfig::CONFIG['host_os'] =~ /linux|bsd/ system "xdg-open #{link}" end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With