Notices
Computer & Technology Related Post here for help and discussion of computing and related technology. Internet, TVs, phones, consoles, computers, tablets and any other gadgets.

./ in unix? why?

Thread Tools
 
Search this Thread
 
Old Jul 3, 2003 | 09:23 AM
  #1  
ADP's Avatar
ADP
Thread Starter
Scooby Regular
 
Joined: Apr 2001
Posts: 3,823
Likes: 1
Talking

Hi all,

I need a good explanation for why the ./ command is used when running scripts etc in unix - struggling to find anything on the web - can anyone explain it??

thanks

AP
Reply
Old Jul 3, 2003 | 09:27 AM
  #2  
SJ_Skyline's Avatar
SJ_Skyline
Scooby Senior
 
Joined: Apr 2002
Posts: 21,922
Likes: 2
From: Limbo
Wink

It is because all good unix boys have beards and wear sandals
Reply
Old Jul 3, 2003 | 09:34 AM
  #3  
ADP's Avatar
ADP
Thread Starter
Scooby Regular
 
Joined: Apr 2001
Posts: 3,823
Likes: 1
Post

yeh but Id rather have a beard and sandals than be affraid of a command prompt
Reply
Old Jul 3, 2003 | 09:40 AM
  #4  
SJ_Skyline's Avatar
SJ_Skyline
Scooby Senior
 
Joined: Apr 2002
Posts: 21,922
Likes: 2
From: Limbo
Post

Reply
Old Jul 3, 2003 | 09:44 AM
  #5  
ragnarock2's Avatar
ragnarock2
Scooby Regular
 
Joined: Jan 2003
Posts: 502
Likes: 0
Post

used to point to the directory where the script is installed i.e. ./ = current directory
Reply
Old Jul 3, 2003 | 10:04 AM
  #6  
boxst's Avatar
boxst
Scooby Regular
 
Joined: Nov 1998
Posts: 11,905
Likes: 0
Post

Hello

Unix looks through the path to find the command. So if your current directory ( . ) is not there it wont find the command. Or worse will find a command that is not the one you want.

So ./command insures that you are running the one in the current directory and MUST be used if the path does not contain the current directory.

Steve.
Reply
Old Jul 3, 2003 | 10:39 AM
  #7  
Figment's Avatar
Figment
Scooby Regular
 
Joined: Jul 2001
Posts: 24,057
Likes: 0
From: deep inside your imagination
Post

Ditto what boxst said
Reply
Old Jul 3, 2003 | 11:57 AM
  #8  
ScoobyJawa's Avatar
ScoobyJawa
Scooby Regular
 
Joined: Aug 2001
Posts: 10,954
Likes: 0
From: Hampshire
Thumbs up

yup - as above!
Reply
Old Jul 3, 2003 | 01:27 PM
  #9  
DominicA's Avatar
DominicA
Scooby Regular
 
Joined: Aug 2000
Posts: 1,771
Likes: 0
Thumbs up

as above, i can confirm this because i've been playing with unix for a few months now..
Reply
Old Jul 3, 2003 | 01:50 PM
  #10  
boxst's Avatar
boxst
Scooby Regular
 
Joined: Nov 1998
Posts: 11,905
Likes: 0
Post

Hello

And I don't wear sandals......... !

Steve.
Reply
Old Jul 3, 2003 | 01:53 PM
  #11  
DrEvil's Avatar
DrEvil
Scooby Regular
 
Joined: Oct 2000
Posts: 8,384
Likes: 0
From: Surrey, UK
Red face

no sandals.. but I do have a small beard.. doh!
Reply
Old Jul 3, 2003 | 02:24 PM
  #12  
ScoobyJawa's Avatar
ScoobyJawa
Scooby Regular
 
Joined: Aug 2001
Posts: 10,954
Likes: 0
From: Hampshire
Wink

I'm sure I've seen you in sandels before Alex

!!!!!!!! GEEK ALERT GEEK ALERT GEEK ALERT !!!!!!!!

Reply
Old Jul 3, 2003 | 02:56 PM
  #13  
DrEvil's Avatar
DrEvil
Scooby Regular
 
Joined: Oct 2000
Posts: 8,384
Likes: 0
From: Surrey, UK
Wink

soon to be uber geek, if next weeks interview goes well
Reply
Old Jul 3, 2003 | 04:15 PM
  #14  
ScoobyJawa's Avatar
ScoobyJawa
Scooby Regular
 
Joined: Aug 2001
Posts: 10,954
Likes: 0
From: Hampshire
Thumbs up

Good luck mate!
Reply
Old Jul 3, 2003 | 04:46 PM
  #15  
chiark's Avatar
chiark
Scooby Regular
 
Joined: Jun 2000
Posts: 13,735
Likes: 0
Post

As mentioned, it isn't necessary if you add "." (the current directory) to the path.

By default, . isn't in the path and this can be very useful sometimes...
Reply
Old Jul 3, 2003 | 05:45 PM
  #16  
stevencotton's Avatar
stevencotton
Scooby Regular
 
Joined: Jan 2001
Posts: 2,710
Likes: 1
From: behind twin turbos
Post

I wouldn't, . in $PATH is bad, google for why
Reply
Old Jul 3, 2003 | 10:51 PM
  #17  
Markus's Avatar
Markus
Scooby Regular
25 Year Member
 
Joined: Mar 1999
Posts: 25,080
Likes: 0
From: The Great White North
Post

ooh, DrEvil in UberGeek, cool, that a new Austin movie?
Reply
Old Jul 4, 2003 | 07:30 AM
  #18  
druddle's Avatar
druddle
Scooby Regular
 
Joined: Mar 2001
Posts: 5,528
Likes: 0
From: Berkshire
Post

Agree with stevencotton. Put explicit paths in $PATH not .

Dave
Reply
Old Jul 4, 2003 | 10:10 PM
  #19  
sempers's Avatar
sempers
Scooby Regular
 
Joined: Nov 2001
Posts: 367
Likes: 0
Post

'cos if someone writes a program called ls (for instance) that does something nice and malicious, and dumps it somewhere, if you're in that somewhere, have . in your path, there's a good chance you'll run that malicious ls instead of /bin/ls

If you're root.... 'ls' could give root permissions to another user, then invoke the real ls (of course) so as not to raise suspicion.

Reply
Related Topics
Thread
Thread Starter
Forum
Replies
Last Post
dogmaul
Computer & Technology Related
17
May 3, 2003 12:46 PM
Dracoro
Computer & Technology Related
7
Apr 7, 2003 10:58 AM
Dracoro
Computer & Technology Related
9
Feb 25, 2003 03:08 PM
SD
Computer & Technology Related
5
Apr 24, 2002 10:29 AM




All times are GMT +1. The time now is 02:12 AM.