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.

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 ?)

Thanks

share|improve this question
add comment

2 Answers

up vote 7 down vote accepted

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 a solute path of your current directory and thus get a path that can be executed.

share|improve this answer
add comment
  • ~ = 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

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

share|improve this answer
    
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
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.