On Fri, 18 Feb 2005 15:03, rob wrote: > On Fri, 2005-02-18 at 13:59 +1300, Christopher Sawtell wrote: > > On Fri, 18 Feb 2005 13:33, rob wrote: > > > I'm just getting: > > > sbminst command not found > > > sbminst-static command not found > > > > cd into the directory where the sbminst is to be found, > > and then say ./sbminst > > > > the dot-slash is important [ ... binary etc ... ]
> Thanks Chris, > That worked. So what exactly does the ./ do? Expanding on what Nick said, making a 'Lesson of the Day'. Unix commands are executed by the shell constructing the full path of the file which has the same name as the command to be executed. This full file name is then passed to the program loader which gets the file & puts the bit patterns into memory and tells the kernel to start the program running. ( It's a bit more complex than that, but in essence that's what happens. ) for example the full path and name of the acroread program on my system is at /usr/local/Adobe/Acrobat7.0/bin/acroread Now it's a proper PITA to have to type all that lot out in order to get acroread to execute. What we want to be able to do is to just type 'acroread' to get it to go, or to associate the command 'acroread' with an icon. This is where the concept of a search path for the directories containing executable programs comes in to play. The shell looks in the colon delimited list of directories in the environment variable PATH. You can examine it with the command:- echo $PATH In my case here's the output: ( Warning to the Posting Police: Long line coming up. You don't need to read this guff, go to next message immediately :-) [EMAIL PROTECTED] ~ $ echo $PATH /usr/local/Adobe/Acrobat7.0/bin/:/usr/kde/3.3/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i386-pc-linux-gnu/gcc-bin/3.3:/opt/Acrobat5:/opt/ghc/bin:/usr/X11R6/bin:/opt/blackdown-jdk-1.4.2/bin:/opt/blackdown-jdk-1.4.2/jre/bin:/usr/qt/3/bin:/usr/kde/3.3/bin:/opt/HelixPlayer:/usr/games/bin Lots of directories. The shell & loader scan the list from left to right and pick the first match. You can check for the full path of the file which is going to be actually executed by using either the command 'which' or the 'type' one we saw yesterday. e.g. :- [EMAIL PROTECTED] ~ $ type acroread acroread is /usr/local/Adobe/Acrobat7.0/bin/acroread [EMAIL PROTECTED] ~ $ which acroread /usr/local/Adobe/Acrobat7.0/bin/acroread Now for the ./command construct. When they appear in a path substituting for a directory name, the shell ( bash ) interprets ( expands ) the tilde '~' and full-stop '.' characters as your home directory and the present working directory respectively. Thus ./command means: 'execute the file 'command' which you will find in the user's present working directory. Similarly ~/command means that the loader should look in your home directory for the file to load and execute. Clear as mud? Excellent! Here endeth the lesson. -- C. S.
