X-www browser compatibility

I want to open html files from a shell script. I know Ubuntu has the x-www-browser command which will open the default browser on the system. I also discovered through some Googling that the command is part of the debian system. I was wondering if the command is available for non-debian distributions. If there is no standard way to open html file in default browser in Linux operating system via command line? Please note that I am using Bash.

+2


a source to share


2 answers


If you want to open an HTML file that is local (and maybe even remote, I will need to check) you can use xdg-open

. It's roughly equivalent to "double-clicking" a file to open it, so it's not limited to html files. Since you want to always open the user's default browser, this will be the same as if they just opened it themselves.

Of course, if they have a system that allows them to open HTML files in a text editor (for example, I've done this for a while), it will backfire. But this is quite rare.



Quick update

I just checked and xdg-open http://google.com

google it in Firefox (my default browser). So it works for non-local files.

+5


a source


You can use xdg-open .



+2


a source







All Articles