Solved

Starting a browser/opening a webpage

Posted on 2002-03-12
11
272 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
  • 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
 
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When you do backups in the Solaris Operating System, the file system must be inactive. Otherwise, the output may be inconsistent. A file system is inactive when it's unmounted or it's write-locked by the operating system. Although the fssnap utility…
Introduction Regular patching is part of a system administrator's tasks. However, many patches require that the system be in single-user mode before they can be installed. A cluster patch in particular can take quite a while to apply if the machine…
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…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

896 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now