./ Why?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers ./ Why?
# 1  
Old 01-26-2005
./ Why?

Searched forums and google with no luck. I simply want to know what ./ does when placed in front of a command. Why and when is it needed? Thanks.
# 2  
Old 01-26-2005
MySQL

The ./ means that you want the system to search for that command in the current directory Smilie
# 3  
Old 01-26-2005
./ says look in your current directory. This is needed if your $HOME directory is not set in your search PATH.
# 4  
Old 01-26-2005
It has nothing at all to do with $HOME not being in $PATH, well unless the script is in $HOME.

UNIX uses an environment variable $PATH as a colon delimited list to define directories to be searched for commands entered into the shell. If $PATH is st to /usr/bin only, when you type ls, it looks in /usr/bin for something called ls, then tries to execute it. If ls is not in /usr/bin, it returns a file not found error.

Typically the path is set to a limited number of directories to make searches quick. If you want to exectute something not in a directory in $PATH, you have to specify the path to it. You can do this explicitely from root (example: /usr/bin/ls ), relative to where you are ( cd / ; usr/bin/ls ), or if it is in the directory you are in, with ./ ( cd /usr/bin ; ./ls ).

You may also use ./ if you want to use a specific version of a program. Say there are two ps commands, one in /usr/bin, the other in /usr/ucb/bin/ps. You want to use the latter, you can type the full path, or cd to /usr/ucb/bin, then run ./ps
# 5  
Old 01-26-2005
Yeah that was sort of a dumb response on my part. Sorry, knee jerk reaction to the question here at work of why users cannot execute scripts in their home directories from other dirs. They need to have HOME in their search path. 98_1LE is right.
# 6  
Old 01-27-2005
Thank you all very much. It's a question I've had for over a year and finally got around to asking. 98, thanks for the detailed explanation.
# 7  
Old 01-27-2005
You may find this article/tutorial useful.

Cheers
ZB
 
Login or Register to Ask a Question

Previous Thread | Next Thread
Login or Register to Ask a Question