This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: beginner a.out question.


>>>>> "Phil" == Phil Taylor <phil@advancedarchitecture.org> writes:

    Phil> Background: new installation of redhat 7.1 on pentium 90. In
    Phil> bash.  When trying to compile beginner C source code (hello.c) I
    Phil> get an output "a.out" that will not run.

    Phil> xxxxxxxcommandlinequotationsxxxxxxxxxx

    Phil> [phil@localhost dir]a.out bash: a.out: command not found

    Phil> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

    Phil> I do not understand my problem here: the command is right there
    Phil> in the directory ("ls" = a.out and other files).  

Cool, but your current directory is not in the PATH and BASH simply can't
find the executable, which is exactly what it (bash!) told you.

You need to specify either the full qualified path, specify a relative path
or add the current directory to the PATH variable (see below).

1) $ ./a.out
2) $ /home/playground/a.out

3) $ PATH="$PATH:."
   $ a.out

But be aware that the third method can be considered a security problem if
you add it to a shell init file, because a user could easily add a program
called e.g. 'cd' (like the well known shell command) to a public directory
which will wipe out all the files in your home directory if you enter the
directory and intend to leave it with e.g. "cd ..".

    [...]
    Phil> Sincerely, Phil

    Phil> (thank you, and my apologies if this msg. is inappropriate.)

well, slightly ...

Claudio


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]