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

I've been searching through the archives and have found a few ways to launch a default web browser pointing to a specififc URL for Win32, but does anyone have any idea how to do the same for Unix and Linux?

Win32:

use Win32::Shell; Win32::Shell::Execute("open", "http://www.perlmonks.org", undef, undef +, "SW_SHOWNORMAL");
Linux: ??
Unix: ??

Replies are listed 'Best First'.
Re: multi-platform browser launch?
by dragonchild (Archbishop) on Feb 27, 2006 at 15:25 UTC
    system( "firefox -browser http://www.perlmonks.org" );

    Or does that not work for you?


    My criteria for good software:
    1. Does it work?
    2. Can someone else come in, make a change, and be reasonably certain no bugs were introduced?
      Linux can't seem to find the firefox binary, tried mozilla (my default) but still nothing.
      typo...nevermind. Thanks!
Re: multi-platform browser launch?
by zentara (Cardinal) on Feb 27, 2006 at 17:41 UTC
    I'll bet firefox will respond as mozilla, so this should work.
    my $linkurl = "http://www.zentara.net"; my $command = "mozilla -remote \"openURL($linkurl)\""; if(fork() == 0){ exec ($command) }

    I'm not really a human, but I play one on earth. flash japh
      hi i also have same kind of problem... is there a way by which i can open a web page in default web browser of the system on which the script is being executed irrespective of platform??? i tried the win 32 code as given above #!/usr/bin/perl use Win32::Shell; Win32::Shell::Execute("open", "http://www.google.com", undef, undef +, "SW_SHOWNORMAL"); but i got the following error ... Cant locate win32/shell.pm in @INC(@INC contains:C:/perl/lib C:/perl/site/lib) at script.pl line 3. pls help!!!

        Code tags would be nice.

        Are you sure on that module? I can't find it on active state or cpan.

Re: multi-platform browser launch?
by leocharre (Priest) on Feb 27, 2006 at 17:39 UTC

    you can do a "whereis firefox" or "whereis mozilla" , that might help find where the program really is

    i guess if this is a script that's not a web thing, and it seems like it's not, then you could also use backticks.. like if you want to get the "date" output into a var, my $date=`date`;