LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   ./ (https://www.linuxquestions.org/questions/linux-newbie-8/a-35026/)

albean 11-09-2002 09:16 PM

./
 
Hi,

I have an executable file in the directory that I'm currently in called XYZ. Why can't I just type XYZ to get it to run? instead I have to type ./XYZ in order to get it to run. what is the ./ all about?

Thanks,
Al

trickykid 11-09-2002 10:32 PM

What directory is it in.. ?? Most likely the case is that the directory your trying to run it in isn't in your PATH, which causes you to have to type ./ in front of it so it finds it to execute it.

GT I.N.C 11-09-2002 10:50 PM

Or i'm pretty sure you could make a file called let's say 'XYZ' and put it in /usr/local/bin and make it link to /whatever/whatever/XYZ instead of editing your path, whatever you feel comfortable with...

#Garry

albean 11-10-2002 02:56 PM

Quote:

Originally posted by trickykid
What directory is it in.. ?? Most likely the case is that the directory your trying to run it in isn't in your PATH, which causes you to have to type ./ in front of it so it finds it to execute it.
Yeah, this is what has me confused. "./" means the directory above the one your in right?

heres is my situation.

if i type "pwd" I get /A/B/C
then I type "ls" and I see XYZ (the executable file i want to run)
but when I type "XYZ" I get : "bash: XYZ command not found"

if I type "./XYZ" it will run
Why?!?!

ok so if I type "cd .." and move into /A/B
and then do an "ls" XYZ is not there.

So why does "./XYZ" work in /A/B/C when "XYZ" does not.

So my newbie question is "What is the ./ all about?"

Confused,
Al

acid_kewpie 11-10-2002 03:13 PM

trickykid answered that question. maybe you didn't actaully read his reply. your current directory is not on your path as there is no conventional reason for this. when you type a command, you will typically be running a program that is installed in your system and on your path. the exception we have in your case is that you are writing your own code, so the program is not installed. if you really want you can add . (the current directory) to your path, but it's not advised, as you could easily get into many daft situations you're just not aware of at the moment.

personally i'm also developeing a program, http://acidrip.thirtythreeandathird.net and it is insatlled on my system, so when i run "acidrip" it runs the installed version. Now, i am still writing it as wel, asnd obviously don't wish to get the developement version confused with the installed one. if my working directory was on my path, then i wouldn't necessarily know which version i was running, however specifying the relative path "./acidrip" means i know what i am running, and i am in control.

you may not quite get the hang of it yet, but it all makes sense when you get used to it. conventions are tehre for a reason.

albean 11-10-2002 09:56 PM

ah... It makes sense now. thanks.


All times are GMT -5. The time now is 03:30 PM.