LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
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 06-05-2004, 12:49 PM   #1
MattG1981
Member
 
Registered: Oct 2003
Posts: 32

Rep: Reputation: 15
Linux Executable File Help (created from a .c file)


Okay .. I am a linux newb but I have to learn it for a college class I am taking. Here is my problem. At school, on their computers, I create the .c file in vi, and then run gcc on it and create the executable file (for this example, we'll call it 'example'). Then from the command line, you just type example and it runs.

On my computer at home (RH9 ... same as at school), I write the program in vi, compile it (no splint errors) and the executable is created without a problem. but when i type in 'example' to run the program, i get an error which says something like:

bash:example:no command found ... or something like that.

Can someone help me, is it a bash setting that I have to change?


also, Same problem happens when I downloaded firefox .. you should just type in firefox in the terminal (in the right directory of course) and it should run, but I get a bash:firefox:no command found ...
 
Old 06-05-2004, 01:28 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 11,851

Rep: Reputation: 737Reputation: 737Reputation: 737Reputation: 737Reputation: 737Reputation: 737Reputation: 737
unlike windows linux does not search the current working directory for a command. It only searches using the path environment. At school, that directory must be in the path.

./ is a shortcut for current working directory. To execute your program:
./your_program_name
 
Old 06-05-2004, 01:44 PM   #3
MattG1981
Member
 
Registered: Oct 2003
Posts: 32

Original Poster
Rep: Reputation: 15
That worked, thanks!

Is there any way that I can make it search the pwd automatically?
 
Old 06-05-2004, 01:53 PM   #4
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
You can add the current directory to your PATH variable.

Open the your bash profile:
vi ~/.bash_profile

Search for: PATH=something

At the end of the line append ":."

Save the file and exit vi

Then execute:
source ~/.bash_profile

Now, the current directory will be included in the search path.
 
Old 06-06-2004, 11:54 AM   #5
MattG1981
Member
 
Registered: Oct 2003
Posts: 32

Original Poster
Rep: Reputation: 15
I am having a hard time find my .bash_profile file ... when I type in vi ~/.bash_profile, it opens up a new blank file in the vi editor.
 
Old 06-06-2004, 12:58 PM   #6
Dark_Helmet
Senior Member
 
Registered: Jan 2003
Posts: 2,786

Rep: Reputation: 369Reputation: 369Reputation: 369Reputation: 369
That's not a problem. Although, I assumed most Linux distributions would install one for each user whether it was empty or not.

No matter... Here is the entire contents of my ~/.bash_profile (it is the default Red Hat includes)
Code:
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
	. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH
unset USERNAME
It's very simple. Lines starting with a # are ignored; they are comments to help the reader understand what the script is doing. First, it tests whether a file named ~/.bashrc exists, and if it does, it sources the file (in a shell script, the period (.) is usually a short-hand for the source command). Then it sets the PATH environment variable and "exports" it (makes it a global value in a sense. The "unset USERNAME" is probably a Red Hat thing and could be wiped (along with the bashrc stuff) if you're so inclined.

Anyway, just modify the PATH line above like mentioned earlier:
Code:
PATH=$PATH:$HOME/bin:.
Save the file, then "source ~/.bash_profile" and that will be it.
 
Old 06-06-2004, 04:45 PM   #7
MattG1981
Member
 
Registered: Oct 2003
Posts: 32

Original Poster
Rep: Reputation: 15
got it! thanks!

I have another question not on this topic .. might as well see if one of you guys can answer it. I went to download the nvidia drivers and it says that I have to exit out of any x-server (gui .. ) setups and I have to run the program from a truly command prompt mode ... how do I enter into just the command prompt?

At the bootup scrren the only options are failsafe, kde, ... etc, but none of those are truly command prompt or whatever it is called.

You guys know what to do?

Oh, and thanks for all the help thus far.

Matt
 
Old 06-06-2004, 04:54 PM   #8
btmiller
Senior Member
 
Registered: May 2004
Location: In the DC 'burbs
Distribution: Arch, Scientific Linux, Debian, Ubuntu
Posts: 4,078

Rep: Reputation: 297Reputation: 297Reputation: 297
Type "init 3" at a command prompt -- that will move the machine down to runlevel 3, which on Red Hat idoes not start X Windows automatically.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to Create an executable file in linux which opens by double-clicking it shivanand Linux - General 5 08-30-2005 12:10 AM
every file is created executable oopsnic Fedora 4 08-15-2005 02:38 AM
how to store a pixmap image created by gdk programm into a new file in linux m.harshavardhan Linux - General 0 05-06-2005 12:57 AM
Java SDK won't install, binary file not executable, yoper linux 2.6 kernel lopoetve Linux - Software 8 10-30-2004 03:03 AM
Create file using 'touch ./tmp.$$', file tmp.3941 is created, why? huangyanfeng Linux - General 1 04-13-2004 03:36 AM


All times are GMT -5. The time now is 09:18 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration