-   Debian (
-   -   a.out does not run (

halfpower 08-18-2005 05:20 PM

a.out does not run
I have a simple "hello world" program in my user directory that I compiled by typing "g++" It produces an output file "a.out" that is also in my user directory. When I type "a.out" at the command prompt I an error message that says something similar to "bash: command not found." Does anyone know why I can't run a.out?

rjlee 08-18-2005 05:34 PM

A program will be run if you provide the exact pathname to it or if it's in a directory listed in the $PATH environment variable.

Try running the program as


halfpower 08-22-2005 08:57 AM

What is the reason for typing './' in './a.out' ?

saman007uk 08-22-2005 10:15 AM

To show that the a.out file is in the current folder.

stefanlasiewski 08-22-2005 02:41 PM

When the Linux shell executes commands, it first looks to see if you specified an explicit path name. If the shell doesn't see a path name, it searches in the PATH environment variable (Look in /usr/local/bin, then /usr/bin, etc).

This is a very unintuitive piece of Unix, and confuses many people. Some people get around this by setting PATH to include the current working directory, '.':

export PATH=".:$PATH"

All times are GMT -5. The time now is 07:34 AM.