Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Hi,

Searching only yields file readers, so hopefully someone can point me in the right direction with a one-liner or something. I'm not looking to parse HTML files, I want to launch a pre-existing HTML file (of known location) with whatever the user's default application is (presumably a browser of some sort). There must be some kind of system call, but I guess I'm blind 'cause I couldn't find anything.

Thanks!

Replies are listed 'Best First'.
Re: Launching HTML File
by Anonymous Monk on Feb 03, 2011 at 23:56 UTC
Re: Launching HTML File
by marto (Cardinal) on Feb 04, 2011 at 14:25 UTC

    I believe Windows systems have start for opening the default browser. You could check this from the command line:

    start http://www.perlmonks.org
      The equivalent command on Mac OS X is open. On Linux, some desktop environments offer a similar capability: Gnome offers gnome-open and KDE offers kde-open. Sometimes, the $BROWSER environment variable is set to the default browser.
Re: Launching HTML File
by zentara (Cardinal) on Feb 04, 2011 at 14:21 UTC
    This works for firefox. It will open firefox if not already running. If running, it will open a new tab or window.
    #!/usr/bin/perl use warnings; use strict; my $linkurl = 'http://google.com'; #my $file = 'my_local_page.html'; #my $command = "firefox $file"; # if(fork() == 0){ exec ($command) } #works #external url my $command = "firefox $linkurl"; if(fork() == 0){ exec ($command) }

    I'm not really a human, but I play one on earth.
    Old Perl Programmer Haiku ................... flash japh