Question

I've used Python webbrowser module and I would love something equivalent in Erlang. What I am trying to do is open a browser window/tab from Erlang.

I can't find anything in the official Erlang documentation. Is there such a thing?

Was it helpful?

Solution

I assume you mean the Python webbrowser module, not webserver. The code for this module is instructive; it looks for various browsers and picks the best option. It interacts with the browser by running a shell command. Firefox supports a -remote command line argument to control an existing Firefox process. (IE seems to be handled simply by passing the url to the iexplore.exe)

The module also detects if it's running on Windows and tries to find out the Windows default browser and use that. Likewise, on Mac OS X, it uses the open command, which will use the default browser.

You should be able to implement this with open_port/2.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top