This is probably a question more for unix systems but because i have it on my Mac Pro i hope i will find an answer here :

When i browse to /Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk/Contents/Home/db/bin

with a cd I can't execute the command startNetworkServer present in bin , instead i can run it via ./startNetworkServer.

However from ~

MacCris:~ cris$ /Library/Java/JavaVirtualMachines/jdk1.7.0_11.jdk/Contents/Home/db/bin/startNetworkServer

it works without ./

Any idea why ? (rights related ?)



This is due to the behaviour of your shell that is running in there Terminal.app. It is probably the bash shell

When you ask the shell to run a command if you provide an absolute path (that is beginning with / as your second one does) it will try to execute that program at that path. If you provide a relative path (i.e. one not starting with /) it will try to create an absolute path by prepending the directories that are in your PATH environment variable to what you typed. As your current directory or . is not on your PATH it cannot find a file to execute. If the path begins with a . the it will repave that by the absolute path of your current directory and thus get a path that can be executed.

  • ~ = home folder nothing else.

  • ./something will execute that something (be it script or binary)
    Writing the full path is the same as executing with ./

  • cd is change directory, so it will not execute

These are all standard unix/linux command line commands

http://linuxcommand.org/learning_the_shell.php http://www.arachnoid.com/linux/shell_programming.html

  • Thanks...but is not that i do not know those commands (basic ones) is that the behaviour is different when i try to execute via full path or when i am in that directory – Cris Dec 20 '13 at 20:58

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .