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
Thanks in advance.
Chaileor
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.
rwxr-xr-x
To change rights to execute your program:
$ chmod u+rwx file_name
file_name is your compiled C program.
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.
# echo $PATH
please ....
surya.
ASKER
This is the output from # echo $PATH:
/usr/bin:/bin:/usr/bin:/us r/local/bi n:/usr/X11 R6/bin/:/u sr/games:/ home/jeff/ bin
I hope this helps.
Chaileor
/usr/bin:/bin:/usr/bin:/us
I hope this helps.
Chaileor
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
is your program in the directory /home/jeff/bin??
if so try the below
unset PATH
PATH=/usr/bin:/bin:/usr/bi n:/usr/loc al/bin:/us r/X11R6/bi n/:/usr/ga mes
export PATH
then run your program with ./whatever-is-the-name
surya.
if so try the below
unset PATH
PATH=/usr/bin:/bin:/usr/bi
export PATH
then run your program with ./whatever-is-the-name
surya.
ASKER
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
export PATH=$PATH:./
Chaileor
ls -lA ./program_name
Most of cases, ./program_name has insufficient permissions.
To be run it has to set +x permissions, btw.