[98327] in RedHat Linux List

home help back first fref pref prev next nref lref last post

Re: Running a C program

daemon@ATHENA.MIT.EDU (David S. Jackson)
Sun Nov 8 06:32:04 1998

Date: Sun, 8 Nov 1998 06:28:01 -0500
From: "David S. Jackson" <dsj@dsj.net>
To: redhat-list@redhat.com
Reply-To: "David S. Jackson" <dsj@dsj.net>
In-Reply-To: <Pine.SUN.3.91.981108101802.17162A-100000@wira2>; from Ronnie Thum on Sun, Nov 08, 1998 at 10:20:34AM +0800
Resent-From: redhat-list@redhat.com

Thus spake Ronnie Thum (csi41298@wira2.cs.usm.my):

> 
> Hi,
> 
> Whenever I run a C program compiled in GCC ver 2.7.2.3, I need to type
> './programname'. 
> Why can't I just type 'programname' ?
> Is there any settings I need to change ?

You've heard several reasonable approaches from others, but what the
heck, here's mine!  :-)

Another thing you can do is create a ~/bin directory and execute your
programs in there.  This isn't necessarily terrific, but it's not too
bad.  I usually run only scripts in here though and save ~/src for C
stuff.  Just make sure ~/bin is in your $PATH variable. You could even
add ~/src to your $PATH if you want, but I wouldn't.  You can use make
to accomplish the same thing.

About your profile and environment settings, such as $PATH.  When you
first log in, your $SHELL (probably bash) will read /etc/profile and
~/.bash_profile for various environment settings and aliases or
functions or whatever is in there.  This ~/.bash_profile is read once
for login, and it usually calls another file, ~/.bashrc.  A ~/.bashrc
is read each time you start another shell.  So, what I recommend is
that you put only a few necessary setup instructions in
~/.bash_profile (they're probably already there), such as source
/etc/profile, and then add a source ~/.bashrc command, if it's not
already there.  This way each successive shell you start up will read
the ~/.bashrc files and inherit the settings from it.

Of course, you can always do a source ~/.bash_profile or source
/etc/profile, or even a source ~/.bashrc at any time you want.  But
just keeping most of your customizations in ~/.bashrc will be easier
in the long run.  Then, when you change your ~/.bashrc and want to
test a new alias or variable in the current shell, remember to source
~/.bashrc in that shell.  Otherwise, the shell won't read the new
configuration.

What do I do?  Heck, most of the time, with smaller programs, I just
run them with ./ in front of them.  For larger programs, I can use
make or run them from a shell script.  Email me personally and I'll
send you a copy of my ~/.bashrc and you can get an idea of what I
mean.  :-)


--
David S. Jackson                           http://www.dsj.net
=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
"It is a greater compliment to be trusted than to be loved."
                         --George Macdonald


-- 
  PLEASE read the Red Hat FAQ, Tips, Errata and the MAILING LIST ARCHIVES!
		http://www.redhat.com http://archive.redhat.com
         To unsubscribe: mail redhat-list-request@redhat.com with 
                       "unsubscribe" as the Subject.


home help back first fref pref prev next nref lref last post