Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Is there a system command in Linux

by tcf03 (Deacon)
on Dec 29, 2007 at 09:44 UTC ( #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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://659461]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2022-05-23 12:18 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you prefer to work remotely?



    Results (82 votes). Check out past polls.

    Notices?