Solved

Starting a browser/opening a webpage

Posted on 2002-03-12
11
276 Views
Last Modified: 2010-04-21
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
Comment
Question by:Sasha_Mapa
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
  • 2
  • +1
11 Comments
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6857766
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
 
LVL 7

Author Comment

by:Sasha_Mapa
ID: 6857812
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
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6857853
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
Industry Leaders: 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!

 
LVL 38

Expert Comment

by:yuzh
ID: 6858957
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
 
LVL 7

Author Comment

by:Sasha_Mapa
ID: 6859056
I need to use this command from an application - it's not for sysadmin work...

Alexander Maryanovsky.
0
 
LVL 51

Expert Comment

by:ahoffmann
ID: 6859827
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
 
LVL 7

Author Comment

by:Sasha_Mapa
ID: 6860432
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
 
LVL 1

Accepted Solution

by:
Sixpax earned 200 total points
ID: 6861929
Try this:

$BROWSER http://www.google.com
0
 
LVL 7

Author Comment

by:Sasha_Mapa
ID: 6861964
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
 
LVL 1

Expert Comment

by:Sixpax
ID: 6862610
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
 
LVL 7

Author Comment

by:Sasha_Mapa
ID: 6862748
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

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

My previous tech tip, Installing the Solaris OS From the Flash Archive On a Tape (http://www.experts-exchange.com/articles/OS/Unix/Solaris/Installing-the-Solaris-OS-From-the-Flash-Archive-on-a-Tape.html), discussed installing the Solaris Operating S…
Installing FreeBSD… FreeBSD is a darling of an operating system. The stability and usability make it a clear choice for servers and desktops (for the cunning). Savvy?  The Ports collection makes available every popular FOSS application and packag…
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question