When running scripts in bash, I have to write ./
in the beginning:
$ ./manage.py syncdb
If I don\'t, I get an error message:
On *nix, unlike Windows, the current directory is usually not in your $PATH
variable. So the current directory is not searched when executing commands. You don't need ./
for running applications because these applications are in your $PATH; most likely they are in /bin
or /usr/bin
.
Your script, when in your home directory will not be found when the shell looks at the $PATH
environment variable to find your script.
The ./
says 'look in the current directory for my script rather than looking at all the directories specified in $PATH
'.
This question already has some awesome answers, but I wanted to add that, if your executable is on the PATH, and you get very different outputs when you run
./executable
to the ones you get if you run
executable
(let's say you run into error messages with the one and not the other), then the problem could be that you have two different versions of the executable on your machine: one on the path, and the other not.
Check this by running
which executable
and
whereis executable
It fixed my issues...I had three versions of the executable, only one of which was compiled correctly for the environment.