Visit Our UNIX and Linux User Community


Help with why I need to use ./


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help with why I need to use ./
# 1  
Old 07-22-2009
Help with why I need to use ./

I use to be able to do a . test.sh shell script but now I have to do ./test.sh

Can someone explain what has most likely happen to cause this.

thank you
# 2  
Old 07-22-2009
Most likely is that the directory you are running test.sh from is not in the PATH
# 3  
Old 07-23-2009
You could be missing a . in the PATH variable. A . denotes the current directory.
# 4  
Old 07-23-2009
Don't confuse . (source the script) with ./ (Under the current directory)

. test.sh = source test.sh

Now the shell looks for the directories in the path ($PATH). If it finds test.sh in any of those directories it will execute or you would have to go to that directory and do a ./test.sh
To avoid doing a ./ do the following.
Edit your .bash_profile or .bashrc file under your home directory.
add the line
export PATH='$PATH:.' -> i.e. add a . to the end of the path

If this doesn't work for you change the single quotes to double quotes.
Run echo $PATH to check if the path is correct.

Previous Thread | Next Thread
Test Your Knowledge in Computers #469
Difficulty: Medium
The NTP pool is a dynamic collection of networked computers that volunteer to provide highly accurate time via the Network Time Protocol to clients worldwide.
True or False?

Featured Tech Videos