Terminal : needs full path to execute a command

Let's suppose i have an application in /Applications/MacPorts/KDE4/myapp.app/Contents/MacOS/myapp.

When i use cd to reach the directory 'MacOS' and then issue the command myapp it says command not found.

But when i issue the command with the full path like /Applications/MacPorts/KDE4/myapp.app/Contents/MacOS/myapp it works.

I had the same problem with mysql inside xampp.

Why is that?


bash in Terminal uses the content of $PATH to look for executables. Usually . (for the current directory) is not part of $PATH (primarily for security reasons), to run commands in the current directory type ./myapp.


This is because when you type "myapp" is not in the current path, just because you cd into a directory does not mean it will be on the path to run the program.

You need to type ./myapp or add "./" to your path so that your shell will look in the current directory for "myapp" etc.