* Reg:gcc
@ 2002-06-26 12:26 Sridhar J (june end)
2002-06-26 12:57 ` Reg:gcc Jos Lemmerling
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Sridhar J (june end) @ 2002-06-26 12:26 UTC (permalink / raw)
To: linux-newbie
Hello
Thanks to all of you who replied promptly to my question. I would like to
clarify one thing. When I compiled the program using gcc, I tried typing
a.out. When that didn't work, I did a ls -l which showed me a file called
a.out*.
Doesn't it mean that a.out is in the current directory? So why I should go
to a parent directory as in ./a.out to execute it?
Regards
Sridhar
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Reg:gcc
2002-06-26 12:26 Reg:gcc Sridhar J (june end)
@ 2002-06-26 12:57 ` Jos Lemmerling
2002-06-26 13:07 ` Reg:gcc Mark Gallagher
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Jos Lemmerling @ 2002-06-26 12:57 UTC (permalink / raw)
To: linux-newbie
On Wed, 26 Jun 2002, Sridhar J (june end) wrote:
> Thanks to all of you who replied promptly to my question. I would like to
> clarify one thing. When I compiled the program using gcc, I tried typing
> a.out. When that didn't work, I did a ls -l which showed me a file called
> a.out*.
>
> Doesn't it mean that a.out is in the current directory? So why I should go
> to a parent directory as in ./a.out to execute it?
yep (a.out is in the current directory).
You just stay in the directory where a.out is located. The first dot in
"./a.out" _means_ the current directory.
If you want to try it, try a "ls -l .", you should see the content of the
current directory (output should be the same as "ls -l").
HTH
--
Jos Lemmerling on Debian GNU/Linux jos(@)lemmerling(.net)
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Reg:gcc
2002-06-26 12:26 Reg:gcc Sridhar J (june end)
2002-06-26 12:57 ` Reg:gcc Jos Lemmerling
@ 2002-06-26 13:07 ` Mark Gallagher
2002-06-26 13:45 ` Reg:gcc Brian Bilbrey
2002-06-26 14:22 ` Reg:gcc Gavin Laking
3 siblings, 0 replies; 5+ messages in thread
From: Mark Gallagher @ 2002-06-26 13:07 UTC (permalink / raw)
To: Sridhar J (june end); +Cc: linux-newbie
Sridhar J (june end) wrote:
> Hello
>
> Thanks to all of you who replied promptly to my question. I would like to
> clarify one thing. When I compiled the program using gcc, I tried typing
> a.out. When that didn't work, I did a ls -l which showed me a file called
> a.out*.
>
> Doesn't it mean that a.out is in the current directory? So why I should go
> to a parent directory as in ./a.out to execute it?
You aren't going to a parent directory in doing that. "." is your
present directory, and ".." is a parent. So if you're in a child of the
directory with a.out in it, then you'd use ../a.out. If you're in the
actual directory it's in, then use ./a.out.
--
Mark Gallagher
http;//cyberfuddle.com/infinitebabble/
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Reg:gcc
2002-06-26 12:26 Reg:gcc Sridhar J (june end)
2002-06-26 12:57 ` Reg:gcc Jos Lemmerling
2002-06-26 13:07 ` Reg:gcc Mark Gallagher
@ 2002-06-26 13:45 ` Brian Bilbrey
2002-06-26 14:22 ` Reg:gcc Gavin Laking
3 siblings, 0 replies; 5+ messages in thread
From: Brian Bilbrey @ 2002-06-26 13:45 UTC (permalink / raw)
To: Sridhar J (june end), linux-newbie
On Wednesday 26 June 2002 05:26, Sridhar J (june end) wrote:
> Doesn't it mean that a.out is in the current directory? So why I should go
> to a parent directory as in ./a.out to execute it?
Sorry, you're not understanding a couple of things. First, "./" is the
*current* directory, not the parent directory (which would be "../").
Second thing. To run a program in Linux, either the program needs to be on
your PATH (type echo $PATH to see) or you need to specify the path to the
executable. To run a program that you've compiled in the current directory,
when said directory is not in your PATH, then ./filename is shorthand for
"run the executable file "filename" that's right here in this directory"
Now, sometimes the obvious idea leaps into people's heads... "Why not make my
home directory on my PATH, so that I can just execute files by name when I
compile them". Resist the temptation. Executing programs should be explicit
and thought about. What I did was to make a directory called bin in my home
directory, and put that on my path. In that way, scripts and programs that
I've tested for personal use, I can MOVE to that location, and run them
easily henceforth. But having ~ (home directory) on your path is a Bad Thing
(tm).
Best of luck,
.brian
--
Brian Bilbrey - bilbrey@orbdesigns.com - http://www.OrbDesigns.com/
Geek for Hire! http://www.OrbDesigns.com/bpages/resume.html
Visit LinuxMuse - I^3 at http://www.LinuxMuse.com/
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: Reg:gcc
2002-06-26 12:26 Reg:gcc Sridhar J (june end)
` (2 preceding siblings ...)
2002-06-26 13:45 ` Reg:gcc Brian Bilbrey
@ 2002-06-26 14:22 ` Gavin Laking
3 siblings, 0 replies; 5+ messages in thread
From: Gavin Laking @ 2002-06-26 14:22 UTC (permalink / raw)
To: linux-newbie
On Wed, 26 Jun 2002 17:56:41 +0530
"Sridhar J (june end)" <sridharj.hyd@cxknetworks.com> wrote:
> Hello
>
> Thanks to all of you who replied promptly to my question. I would like to
> clarify one thing. When I compiled the program using gcc, I tried typing
> a.out. When that didn't work, I did a ls -l which showed me a file called
> a.out*.
>
> Doesn't it mean that a.out is in the current directory? So why I should go
> to a parent directory as in ./a.out to execute it?
Hi,
a.out* means that the file is executable (well, had its 'executable' bits set anyway), it might be coloured green as well depending on your system. ./ simply gives the path to the file, it means "current directory".
If you type: 'ps aux' (no single quotes) in your terminal or console, then Linux first checks all of the directories set in the environment variable "PATH" for an executable file called 'ps'. It it doesn't find one, then it reports that. If it does find one, then it executes it. Lets say you just compiled 'a.out', it is located here: '/home/sridhar/sources', if that path is NOT in the environment variable PATH, then when you type 'a.out', Linux cannot find it in the path and therefore cannot execute it. You can do three things here. 1) Add '/home/sridar/sources' to your path, 2) type ./a.out (which tells Linux to look in the current directory), or 3) with the correct priveledges, you could copy 'a.out' to a place that is mentioned in your environment variable 'PATH' (usually, '/usr/bin', or '/usr/local/bin' (there are others but it could take all day for me to list the possibilities.))
./ doesn't mean parent. It means "this".
../ means parent. It doesn't mean "this".
Finally, rename 'a.out' to something you will recognise- having a disk full of 'a.out's can get confusing :-) (rename = mv)
Hope that helps,
G
--
Gavin Laking
1:52pm up 20:25, 3 users, load average: 0.27, 0.11, 0.02
http://www.gavinlaking.co.uk/
--
-
To unsubscribe from this list: send the line "unsubscribe linux-newbie" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.linux-learn.org/faqs
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2002-06-26 14:22 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-26 12:26 Reg:gcc Sridhar J (june end)
2002-06-26 12:57 ` Reg:gcc Jos Lemmerling
2002-06-26 13:07 ` Reg:gcc Mark Gallagher
2002-06-26 13:45 ` Reg:gcc Brian Bilbrey
2002-06-26 14:22 ` Reg:gcc Gavin Laking
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.