Congratulations to AcaCandy on her 100,000th post!
There's no such thing as a stupid question, but they're the easiest to answer.
JoinTour
Login
 
Tag Cloud
acer black screen blue screen boot bsod computer connection crash css dell display drive driver drivers email error ethernet excel firefox firefox 3 game hard drive internet internet explorer itunes laptop linux malware monitor network networking nvidia outlook outlook 2003 outlook 2007 outlook express partition problem router slow software sound trojan usb video virus vista windows windows xp wireless
UNIX/Linux
Search
Search in:
 
Advanced Search
Tech Support Guy Forums > Operating Systems > UNIX/Linux >
C Program not running


HELLO AND WELCOME! Before you can post your question, you'll have to register -- it's completely free! Click here to join today! We highly recommend that you print a copy of our Guide for New Members. Enjoy!

Closed Thread
 
Thread Tools
dileep's Avatar
Junior Member with 9 posts.
 
Join Date: Oct 2003
02-Nov-2003, 12:19 AM #1
C Program not running
Hi

While running C Programs in RedHat Linux, i am using the following commands

$ cc Hello.c (it is compiling and giving the binary file a.out)

After that , to run the program I am using the following command

$ a.out

I am getting error as....

bash: a.out: command not found.


How o compile and run C programs???

Thanks in Advance

regards
Dileep
codejockey's Avatar
Senior Member with 1,410 posts.
 
Join Date: Feb 2002
02-Nov-2003, 01:39 AM #2
I suspect the problem is that your PATH does not include the current directory (.). Note that this is standard for the root ID, as to include the current directory in root's PATH is a serious security risk. Try running your program using a command such as: ./a.out and see if results improve.

Hope this helps.
__________________
The slowest component still sits at the keyboard.
dileep's Avatar
Junior Member with 9 posts.
 
Join Date: Oct 2003
02-Nov-2003, 09:47 PM #3
Thank you CodeJockey.

It worked for me.
It gave result without any error.

In UNIX, we say simply a.out
But in LINUX, we say ./a.out

Why is this difference coming between CUI and GUI?

Thanks once again.

regards,
Dileep
codejockey's Avatar
Senior Member with 1,410 posts.
 
Join Date: Feb 2002
03-Nov-2003, 04:04 PM #4
You're welcome for the help. Now, to answer your other questions ...

Both Unix and Linux will allow you to include the current directory in your PATH. If you choose to do so, the current directory will be searched for an executable program that matches the name you specify on the command line (or invoke from a run-box in a GUI such as KDE). I suspect that your PATH under Unix included the current directory but your PATH under Linux did not. You can check this by giving the command:

echo $PATH

at the command line and reviewing the output. If the current directory is included in your PATH, you will see a single period specified between other colon-delimited values. For example, here is the output from echo $PATH on my current system when I am a normal user:

/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/opt/www/htdig/bin:/opt/kde/bin:/usr/lib/qt-3.0.4/bin:/usr/share/texmf/bin:.:/usr/lib

My PATH specifies which directories will be searched to find any executable programs that I invoke. Note that near the end of this string is a single period character between two colon characters; the single period specifies that my current directory should be searched.

In contrast, here is the output of the echo $PATH command on the same system when I am the root user (super-user):

/usr/local/sbin:/usr/sbin:/sbin:/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/opt/www/htdig/bin:/opt/kde/bin:/usr/lib/qt-3.0.4/bin:/usr/share/texmf/bin:/usr/lib

Note that it does not include a single period between two colons. This means that the current directory will not automatically be searched for an executable invoked by the root user (this is a security safeguard).

Similarly, you may choose either a command-line interface or a GUI interface to interact with the operating system, but this does not affect whether the current directory will be searched for an executable with the name you specify.

Hope this helps.
__________________
The slowest component still sits at the keyboard.
dileep's Avatar
Junior Member with 9 posts.
 
Join Date: Oct 2003
03-Nov-2003, 09:52 PM #5
Thanks for clarifying my doubt.

After that , I tried with the following command

echo $PATH (Logged as Normal User)

it showed me

/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/home/dileepeduri/bin

How should I add PATH ??? that is any path or that period for C programs

Thanks in Advance

regards
Dileep
codejockey's Avatar
Senior Member with 1,410 posts.
 
Join Date: Feb 2002
03-Nov-2003, 11:15 PM #6
Again, you're welcome for any help I've provided. You can modify your PATH in several ways. The syntax varies slightly depending upon which shell you are using (typcially bash, sh or ksh but others are possible). The following example assumes that you are running bash, sh or ksh. To add the current directory to your PATH, you can type:

PATH="${PATH}:."

at the command line. This will add the current directory to the end of your PATH. You can also add this command to a login script such as .bashrc, .profile or .kshrc in your home directory; that way, the command will be executed automatically at each login, and the current directory will be added to your PATH. Your PATH sets the search directories for all commands you attempt to execute, whether those commands are implemented as scripts or compiled executables.

Hope this helps.
__________________
The slowest component still sits at the keyboard.
Closed Thread

THIS THREAD HAS EXPIRED.
Are you having the same problem? We have volunteers ready to answer your question, but first you'll have to join for free. Need help getting started? Check out our Welcome Guide.


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
WELCOME TO TECH SUPPORT GUY! Are you looking for the solution to your computer problem? Join our site today to ask your question -- for free! Our site is run completely by volunteers who help people like you solve computer problems. See our Welcome Guide to get started.



Thread Tools


You Are Using:
Server ID
Advertisements do not imply our endorsement of that product or service.
All times are GMT -4. The time now is 03:39 AM.
Copyright © 1996 - 2008 TechGuy, Inc. All rights reserved.
Powered by vBulletin, Copyright © 2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Powered by Cermak Technologies, Inc.