Reputation:
I want to open html files from a shell script. I know that Ubuntu has a command x-www-browser that will open the default browser on the system. I also found via some Googling that the command is part of the debian system. I was wondering if the command is available on non debian based distros. If it isn't is there a standard way of opening an html file in the default browser on a linux OS via command line? Note that I'm using Bash.
Upvotes: 3
Views: 3727
Reputation: 37065
If you are wanting to open an HTML file that is local (and maybe even remote, I'd have to check), you can use xdg-open
. This is the rough equivalent to "double-clicking" on a file to open it, so it's not limited to html files. Since you want to always open in the user's default browser, this would be the same as if they just opened it themselves.
Of course, if they have their system set up to have HTML files open in a text editor (like I did for awhile), this would backfire. But that's pretty rare.
I just checked and xdg-open http://google.com
brought up Google in Firefox (my default browser). So it does work for non-local files.
Upvotes: 5