?
Solved

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

Posted on 2005-03-10
8
Medium Priority
?
339 Views
Last Modified: 2013-12-15
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
Comment
Question by:Chaileor
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 8

Expert Comment

by:marxy
ID: 13514419
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
 
LVL 9

Expert Comment

by:gtkfreak
ID: 13514979
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
 

Author Comment

by:Chaileor
ID: 13522790
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
DFW AZURE MEETUP TONIGHT FRI 6PM

We will be discussing what Azure Stack is, how does it fit into the suit of offerings that Azure has currently, and where can it fit into your organizations technology stack. We will also be discussing limitations of the platform while covering various applicable scenarios.

 
LVL 7

Expert Comment

by:surya_prabhakar
ID: 13525356
can you give the output of

# echo $PATH
please ....


surya.
0
 

Author Comment

by:Chaileor
ID: 13526724
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
 
LVL 3

Accepted Solution

by:
mike_mian earned 2000 total points
ID: 13527508
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
 
LVL 7

Expert Comment

by:surya_prabhakar
ID: 13529271
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
 

Author Comment

by:Chaileor
ID: 13529711
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

Python: Series & Data Frames With Pandas

Learn the basics of Python’s pandas library of series & data frames and how we can use these tools for data manipulation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
Suggested Courses
Course of the Month13 days, 13 hours left to enroll

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question