Link to home
Start Free TrialLog in
Avatar of Chaileor
Chaileor

asked on

Can't run compiled c files that are not in /bin/ or /usr/bin/

I recently installed Mandrake 10.1 and from my experience I should be able to execute compiled c files from a shell by just typing ./program_name but this doesn't work. The error I get is command not found. I set the permissions to 777 on the directory that contains the file and the file that I was trying to execute.  I can run the compiled c file when I copy it to the /bin/ or /usr/bin/ folders but not in other folders.  I've also tried running the file as root and it still doesn't work.  Does anyone know how I can get files to execute from any folder.

Thanks in advance.

Chaileor
Avatar of marxy
marxy

Show report of
ls -lA ./program_name

Most of cases, ./program_name has insufficient permissions.
To be run it has to set +x permissions, btw.
Ensure that the following attributes are on your file:
rwxr-xr-x
To change rights to execute your program:
$ chmod u+rwx file_name

file_name is your compiled C program.
Avatar of Chaileor

ASKER

My permissions are all fine.   The attributes on my file are rwxrwxrwx.  I also set them to rwxrwxrwx on the directory containing the file just to be safe.  I thought there would be a simple solution to this but I can't seem to find an answer so I think that an answer to this is worth more points than I had originally set.
can you give the output of

# echo $PATH
please ....


surya.
This is the output from # echo $PATH:
/usr/bin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin/:/usr/games:/home/jeff/bin

I hope this helps.

Chaileor
ASKER CERTIFIED SOLUTION
Avatar of mike_mian
mike_mian

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
is your program in the directory /home/jeff/bin??

if so try the below
unset PATH
PATH=/usr/bin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin/:/usr/games
export PATH

then run your program  with ./whatever-is-the-name

surya.

Thanks mike_mian, I just needed to add ./ to my path variable and now everything runs great.  To permanently add that to my path I just edited /etc/profile and added the line

export PATH=$PATH:./

Chaileor