Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

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?

share|improve this question
add comment

2 Answers 2

up vote 4 down vote accepted

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.

share|improve this answer
1  
yes that was it. I hadn't thought of that but it is very logical. Both answers are the same. I didn't know which to accept so i accepted the one submitted first. –  miako Dec 9 '12 at 20:03
add comment

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.

share|improve this answer
2  
I strongly recommend against adding . to $PATH. A simple malicious ls placed in a public directory can lead to a lot of problems. –  patrix Dec 9 '12 at 19:40
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.