Solved

Starting a browser/opening a webpage

Posted on 2002-03-12
11
271 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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

I promised to write further about my project, and here I am.  First, I needed to setup the Primary Server.  You can read how in this article: Setup FreeBSD Server with full HDD encryption (http://www.experts-exchange.com/OS/Unix/BSD/FreeBSD/A_3660-S…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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…

744 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

12 Experts available now in Live!

Get 1:1 Help Now