Link to home
Start Free TrialLog in
Avatar of Sasha_Mapa
Sasha_Mapa

asked on

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.
Avatar of ahoffmann
ahoffmann
Flag of Germany image

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
Avatar of Sasha_Mapa
Sasha_Mapa

ASKER

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.
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)
Avatar of yuzh
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.

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

Alexander Maryanovsky.
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
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.
ASKER CERTIFIED SOLUTION
Avatar of Sixpax
Sixpax

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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
Thanks, I think I'll use that environment variable. If there's none, I'll ask the user to set one...

Alexander Maryanovsky.