LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 11-09-2002, 09:16 PM   #1
albean
Member
 
Registered: Sep 2002
Distribution: fc2
Posts: 113

Rep: Reputation: 15
./


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
 
Old 11-09-2002, 10:32 PM   #2
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 269Reputation: 269Reputation: 269
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.
 
Old 11-09-2002, 10:50 PM   #3
GT I.N.C
Member
 
Registered: May 2002
Location: Australia, Sydney, St.Clair
Distribution: Rh 7.3
Posts: 836

Rep: Reputation: 30
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
 
Old 11-10-2002, 02:56 PM   #4
albean
Member
 
Registered: Sep 2002
Distribution: fc2
Posts: 113

Original Poster
Rep: Reputation: 15
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
 
Old 11-10-2002, 03:13 PM   #5
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
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.
 
Old 11-10-2002, 09:56 PM   #6
albean
Member
 
Registered: Sep 2002
Distribution: fc2
Posts: 113

Original Poster
Rep: Reputation: 15
ah... It makes sense now. thanks.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 12:07 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration