gcc compile on cmd line, then run, get: bash: hello: command not found [Archive] - C Board

PDA

View Full Version : gcc compile on cmd line, then run, get: bash: hello: command not found


cjtotheg
11-03-2001, 11:08 AM
I'm simply trying to compile and run a c program from command line in Linux Red Hat 7.2. Here are my steps:

1. I compile a simple hello world program using this:

gcc -g -Wall -ansi -pedantic -ohello -hello.c

2. It runs through just fine, no errors or warnings, so then at the command line, I enter simply:

hello

3. And it tells me:

bash: hello: command not found

All I want it to do is spit out, "Hello World" and it won't... so maybe I'm in the wrong shell, or I have to put a command in that says execute hello or maybe the compile command used isn't actually creating an executable. As you can see, I'm very new to this. Got any suggestions?
Thanks.

Salem
11-03-2001, 12:00 PM
type
./hello

You could put . in your $path, but that is generally considered to be a security risk.

> or maybe the compile command used isn't actually creating an executable
Do an 'ls' to find out then

cjtotheg
11-03-2001, 12:23 PM
ahhh yes... thanks for that.... it works just fine... so precise. Have to tell it which directory it's in I guess.

Unregistered
11-03-2001, 01:20 PM
>>Have to tell it which directory it's in I guess.<<

exactly...like salem said. you can change your $PATH enviroment varible to include the current directory, but it's typically not done.

Justin W
11-14-2001, 10:28 AM
but it's typically not done

Yes, it is considered a possible security risk. Many Windows worms use the current directory loophole. I don't know how, that's just what I've read.