Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 283
  • Last Modified:

Starting a browser/opening a webpage

Is there a command which would bring up the default browser and display a given URL and which would work on most unix systems?

For example, on windows you would do:
"rundll32 url.dll,FileProtocolHandler http://www.google.com/"

Currently, on unix, I'm doing:
"netscape -remote openURL(http://www.google.com/)" and if that returns a non-zero value, I do:
netscape http://www.google.com/

This however has several problems:
1. It only works if the user has netscape.
2. If netscape if not your preferred browser, it annoys the user.
3. If netscape *is* already open, it just shows the page without bringing it to front (as reported by some users, I haven't witnessed it myself)

Alexander Maryanovsky.
0
Sasha_Mapa
Asked:
Sasha_Mapa
  • 5
  • 3
  • 2
  • +1
1 Solution
 
ahoffmannCommented:
There is no general way/command to do that.

Depending on your UNIX flaviour you might do it, but you always need to know at least following:
  1) program to be used (might also be a script)
  2) PATH where to find program
  3) underlaying window manager and/or desktop system
0
 
Sasha_MapaAuthor Commented:
Hmm, I see. Is there at least a general way to do this on specific unix flavors? (so at least I don't have to switch between browsers).

Alexander Maryanovsky.
0
 
ahoffmannCommented:
AFAIK in Gnome and KDE desktop you can associate file types/extensions with a program, like you do in M$ world.
In such a environment it might work, if you know the appropriate link file, or how to call the specific function (I don't know, sorry)
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
yuzhCommented:
May be you can use a dummy user as a template to configure Netscape.

    1. login as the dummy user, run netscape, setup all your preferences/options etc.

    2. use the copy the .netscape dir from the dummy user's
home dir to your target user.
    cd ~targetusr/.netscape
    edit preferences.js to replace the dummy login name with the target user login name.
    change the dir/file permissions in .netscape for the target user.

   
0
 
Sasha_MapaAuthor Commented:
I need to use this command from an application - it's not for sysadmin work...

Alexander Maryanovsky.
0
 
ahoffmannCommented:
hmm, how about programming a little loop like this:

  found = ''
  foreach browser (konqueror mosaic netscape opera w3m) {
     foreach dir (eval $PATH) {
          found = $dir/browser
          break if exists $found
     }
   
  }
  case found in {
    'netscape': $found your-url
    'w3m':     $found http://your-url
...
    '': print 'Error: no browser found'
  esac
0
 
Sasha_MapaAuthor Commented:
Well, that solves only problem No. 1... If no one can suggest a way to do this under KDE, I think I'll ask the user for the name of his browser and use that.

Alexander Maryanovsky.
0
 
SixpaxCommented:
Try this:

$BROWSER http://www.google.com
0
 
Sasha_MapaAuthor Commented:
Hmm, that seems to work on my Mandrake laptop... Could you point me to a piece of documentation about that system variable so I can be sure that this works correctly and under which versions of KDE?

Alexander Maryanovsky.
0
 
SixpaxCommented:
It seems to be a recently introduced standard in the Linux world, not sure about other flavors of UNIX.

It's listed in the man page for environ(5) and refrences the following web page:

http://www.tuxedo.org/~esr/BROWSER
0
 
Sasha_MapaAuthor Commented:
Thanks, I think I'll use that environment variable. If there's none, I'll ask the user to set one...

Alexander Maryanovsky.
0

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 5
  • 3
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now