Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 344
  • Last Modified:

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
0
Chaileor
Asked:
Chaileor
1 Solution
 
marxyCommented:
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.
0
 
gtkfreakCommented:
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.
0
 
ChaileorAuthor Commented:
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.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
surya_prabhakarCommented:
can you give the output of

# echo $PATH
please ....


surya.
0
 
ChaileorAuthor Commented:
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
0
 
mike_mianCommented:
as you are typing ./progname your path is not used.
does your program make any system calls to other programs? you may be getting an error from a call it is making.
are you doinf any setuid in the program or is it a simple "hello world" prog?


0
 
surya_prabhakarCommented:
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.

0
 
ChaileorAuthor Commented:
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
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now