[NTLUG:Discuss] Shortcuts

Steve Baker sjbaker1 at airmail.net
Fri Aug 24 08:58:58 CDT 2001


> Patrick Parks wrote:
> 
> I have a easy question, that I can not seem to find an answer for. I have a program, lets say Netscape browser that I want to create a shortcut for in my desktop. In order to get this program to launch, I have to cd to the directory where it is located "cd /usr/local/netscape6.1" then I have to type "./netscape" to get it to run, not just netscape. My question is, how would I type this in the command section of the launcher that I am trying to create, and why do I have to do a "./" to get it to run, it is the first program I have had to do this with, and I do not understand what the "./" does. Could someone please enlighten me? Thanks.

OK - let's take this in three parts.

Firstly, you don't have to 'cd' into it's directory.  In your case, you should be able
to type:

   /usr/local/netscape6.1/netscape

...and it'll run from any directory you happen to be in.

So, the second issue is why when you *do* 'cd' into that directory do you need the
"./" in front of the filename.

Well, Linux (and UNIX) searches for programs by looking at the 'PATH' variable
in your current shell.  Type this:

   echo $PATH

...and you'll see a colon-separated list of path names.  Mine says:

  /usr/local:/usr/local/bin:/opt/kde/bin:/sbin:/bin:/usr/sbin:/usr/bin:
  /usr/X11R6/bin:/usr/lib/pgsql/bin:/u/steve/bin:/u/steve/scripts:/usr/demos/bin

...which means that Linux will look in each of those directories in turn in
order to find the file containing the program who's name you typed.

Notice that your /usr/local/netscape6.1 directory isn't in that list. Neither
is "." - the current directory - so unless you tell the shell to look there
explicitly by putting a './' in front of the filename, it won't find your
program there.

You can actually change the value of the PATH variable (I did - that's how
come /u/steve/bin and /u/steve/scripts are on my search path)...and you could
even put ".:" at the start or ":." at the end to add the current directory
to that search path.  Then you could 'cd' to your netscape directory and type
just "netscape" without the "./" and because "." is now in your search path,
Linux will find it.

HOWEVER, it's generally advised that you don't do that - both for security
reasons (it would be easy for a bad guy to drop a file called "ls" into
your home directory and have that program do something nasty. Then, the
next time you do an 'ls'....KABOOM!)...it's also a little dangerous
because you might write some program of your own and accidentally give it
the same name as some system program - resulting in strange bugs in your
system.  This generally happens with programs named "test" - which stomps
all over the system program of the same name...resulting in very weird and
occasionally fatally dangerous errors!

So, what you *CAN* do to make getting at netscape easier is any one of
the following:

  1) Copy the 'netscape' binary into one of the directories already in
     your search path.  (/usr/local/bin might be OK)

  2) Make a symbolic link from /usr/local/bin/netscape to your netscape
     executable.

  3) Add /usr/local/netscape6.1 to your PATH variable (change your shell
     startup script to add:

       PATH=$(PATH):/usr/local/netscape6.1
       export PATH

     or

       setenv PATH $(PATH):/usr/local/netscape6.1

     ...if you are a csh/tcsh person.

   4) You could make an 'alias' to run netscape:

        alias netscape /usr/local/netscape6.1/netscape

      ...put that into your shell startup script.

   5) You could create a shell script to run netscape and put that
      into some directory in your search path.

...it's something of a matter of taste which you choose to do.  I'd probably
go with an 'alias' if it were me.

I'm a little suprised that netscape ended up in /usr/local/netscape6.1 in the
first place.  /usr/X11/bin is a more usual place for it - and that's already
on your search path.  Is there some kind of 'install' thing you need to run
in your netscape directory to put everything in the correct places?


----------------------------- Steve Baker -------------------------------
HomeMail : <sjbaker1 at airmail.net>   WorkMail: <sjbaker at link.com>
HomePage : http://web2.airmail.net/sjbaker1
Projects : http://plib.sf.net       http://tuxaqfh.sf.net
           http://prettypoly.sf.net http://tuxkart.sf.net
           http://freeglut.sf.net   http://toobular.sf.net




More information about the Discuss mailing list