1
votes

I have an executable located in PATH, but it cannot be found when I type the command.

The result from $PATH is: -bash: /Users/aridyckovsky/.rvm/gems/ruby-2.1.0/bin:/Users/aridyckovsky/.rvm/gems/ruby-2.1.0@global/bin:/Users/aridyckovsky/.rvm/rubies/ruby-2.1.0/bin:/Library/Frameworks/Python.framework/Versions/3.3/bin:/opt/local/bin:/opt/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/opt/X11/bin:/usr/local/git/bin:/usr/local/mysql/bin:/Users/aridyckovsky/.rvm/bin: No such file or directory`

Specifically, I am trying to execute mongod in /usr/local/bin, but the result is -bash: mongod: command not found. I can run other executables in the same location, however. Any ideas?

1
so what does ls -l /usr/local/bin/mongod say ? - nos
do a 'ls -l full path to your file and post it here. - michael501
the result is: lrwxr-xr-x 1 aridyckovsky admin 34 Nov 11 13:43 /usr/local/bin/mongod -> ../Cellar/mongodb/2.4.8/bin/mongod - adyckovsky
@user3192285 Just because the symlink exists doesn't mean the actual script exists (and you will get the same error if the symlink is broken). Can you also do ls -l /usr/local/Cellar/mongodb/2.4.8/bin/mongod - Reinstate Monica Please
Looks like there is not existing script ls: /usr/local/Cellar/mongodb/2.4.8/bin/mongod: No such file or directory - adyckovsky

1 Answers

2
votes

You'll get that error when you try to execute $PATH as a command.

$ $PATH
bash: /home/glennj/bin:...:/opt/tcl/8.6/bin: No such file or directory

In bash, use the type builtin to find things:

$ type mongod
mongod is /usr/bin/mongod

Use type -a to also show aliases and functions

$ type -a ls
ls is aliased to `ls -F'
ls is /bin/ls
$ type -a git
git is a function
git () 
{ 
    case "$1" in 
        push | pull)
            if (( $# == 1 )); then
                local branch=$(git_current_branch);
                if [[ -n $branch ]]; then
                    set -- $1 origin "$branch";
                    echo git "$@";
                else
                    echo "You're not in a git-managed directory" 1>&2;
                    return;
                fi;
            fi
        ;;
    esac;
    command git "$@"
}
git is /usr/bin/git