Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Is there a system command in Linux

by tcf03 (Deacon)
on Dec 29, 2007 at 09:44 UTC ( [id://659461] : note . print w/replies, xml ) Need Help??


in reply to Is there a system command in Linux

#!/usr/bin/perl use strict; use warnings; $ENV{PATH}="/usr/bin:/usr/local/bin:/bin"; system("firefox http://www.perlmonks.org");

If you want a default browser, and its under your control you could have users set an environmental var like export BROWSER='/usr/bin/firefox' Other than that, certain distros may have some facility for getting at that, but it would most likely be distro specific. Your mileage may vary.

Untested, but you could also try something such as
#!/usr/bin/perl # use strict; use warnings; $ENV{PATH}="/usr/bin:/usr/local/bin:/bin"; my @browsers = qq|firefox lynx|; USEBROWSER: { for (@browsers) { my $status = (system("$_ http://www.perlmonks.org") == 0 ) ? 0 + : 1; last USEBROWSER if $status == 0; } print "No suitable browser was found...\n"; }
Ted
--
"That which we persist in doing becomes easier, not that the task itself has become easier, but that our ability to perform it has improved."
  --Ralph Waldo Emerson