Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
 |
10-12-2003, 12:32 AM
|
#1
|
Member
Registered: May 2003
Posts: 80
Rep:
|
can't execute c++ binaries, "permission denied"... even though permission is 777
i'm having trouble executing simple c++ binaries. bash returns a permission denied error, even though i set the file's permissions to 777. i'm using g++ compiler on RH9. for some reason it works on my laptop, also RH9. does it have something to do with installed c++ libraries? any suggestions on how to fix it?
thanks
|
|
|
10-12-2003, 03:59 AM
|
#2
|
Member
Registered: Oct 2003
Location: Australia
Distribution: Redhat 9
Posts: 95
Rep:
|
I think we would need a little more info than you have provided to determine what is going wrong..
Can you paste the command you entered, the error output and anything else that might help us determine what's going on.
It is possible that your binary is attempting to load a shared object for which you dont have read permissions..
If you are not getting much info on what is going bad, you can do an strace on your binary to see if it is something like that.
Code:
strace -e trace=file <your_executable>
This will allow you to see all system calls to file routines and see if it is your binary accessing something or not, also you will see what it failed to open.
Cheers.
|
|
|
10-12-2003, 09:22 AM
|
#3
|
LQ Newbie
Registered: Sep 2003
Location: Mount Isa, Queensland, Australia
Distribution: RedHat
Posts: 13
Rep:
|
Hi SerfurJ
Who ownes the directory where the executable will end up? Perhaps it needs 777 also. And if you are trying to execute from the current directory, is it in the path. BF
|
|
|
10-13-2003, 06:48 PM
|
#4
|
Member
Registered: May 2003
Posts: 80
Original Poster
Rep:
|
mr_segfault,
i don't get much info. here's what i enter along with the output:
$ ./hello-test
bash: ./hello-test: Permission denied
alternatively
$ bash hello-test
hello-test: hello-test: cannot execute binary file
trying what you suggested:
$strace -e trace=file ./hello-test
strace: exec: Permission denied
execve("./hello-test", ["./hello-test"], [/* 53 vars */]) = 0
i'm not sure what to make of that.
big fred,
i tried that... no banana. i'm using "./" in front of the binary, so it doesn't have to be in the path.
any more ideas? how could i find out if i don't have read permissions for a shared object?
thanks
|
|
|
10-13-2003, 06:52 PM
|
#5
|
Member
Registered: Oct 2003
Location: Australia
Distribution: Redhat 9
Posts: 95
Rep:
|
It looks like you may not have permission to run/call exec.. I'll do some testing and get back to you..
Cheers.
|
|
|
10-14-2003, 04:59 PM
|
#6
|
Member
Registered: Mar 2003
Distribution: Debian
Posts: 275
Rep:
|
SerfurJ,
Is your filesystem mounted with the noexec option? "grep -i exec /etc/fstab" or "mount|grep -i exec". Have you configured any of the Access control systems. (I don't know what Redhat includes).
Can you run a shell script (or simple c program) from this directory. It may not be related to c++ at all.
Good Luck,
chris
|
|
|
10-14-2003, 10:01 PM
|
#7
|
Member
Registered: May 2003
Posts: 80
Original Poster
Rep:
|
hey good suggestions chris. the drive where i am running these binaries is separate from my linux installation drive, so that seemed like a pretty good explanation. unfortunately, that wasn't it. here's the entry for the drive where it's running from:
/dev/hdh1 /home/jason/mydocs ext3 defaults,user 1 1
i've never heard of any "access control systems" in redhat. is this a gui configurator in debian?
i tried copying the cat binary to the directory that i'm trying to run the c++ binaries from. here's the input/output:
$./cat hello.cc
bash: ./cat: Permission denied
it's funny that perl scripts run from this drive. i think we're on to something. i copied the c++ binary to my other drive and it worked. so what else would keep binaries from running on a mounted filesystem?
|
|
|
10-14-2003, 10:27 PM
|
#8
|
Senior Member
Registered: Nov 2002
Location: Silly Con Valley
Distribution: Red Hat 7.3, Red Hat 9.0
Posts: 2,054
Rep:
|
can you try to change that fstab entry to something like this?
/dev/hdh1 /home/jason/mydocs ext3 defaults,user,exec 1 1
i guess you'll have to log out and log in as root so you can unmount it and remount it.
|
|
|
10-14-2003, 11:09 PM
|
#9
|
Member
Registered: Mar 2003
Distribution: Debian
Posts: 275
Rep:
|
This option implies the options noexec, nosuid, and nodev (unless overridden by subsequent options, as in the option line user,exec,dev,suid). Quothe the mount man page on the user option. Makes sense, I guess.
|
|
|
10-17-2003, 09:26 AM
|
#10
|
Member
Registered: May 2003
Posts: 80
Original Poster
Rep:
|
i just removed the user option and that fixed it. thanks a lot bastard23 et al. for the help.
|
|
|
01-23-2007, 08:31 PM
|
#11
|
LQ Newbie
Registered: May 2005
Posts: 9
Rep:
|
Thanks very much GNU brothers
I am new in ubuntu with two years of GNU experience. GNU systems like linux are marvelous and you, the community too. Thanks for your help. The solution and the process to diagnosticate the problem help me too. Thanks. Adding "Mount" option "exec" is the key... eh ;-)
$more /etc/fstab | grep exec
/dev/hda9 /home/user/docs ext3 defaults,user,exec 0 2
|
|
|
05-28-2008, 03:57 PM
|
#12
|
LQ Newbie
Registered: Jul 2007
Distribution: Debian
Posts: 15
Rep:
|
Thank you very much -- had the same problem here. This was pretty difficult to track down...
|
|
|
02-19-2009, 05:48 AM
|
#13
|
LQ Newbie
Registered: Feb 2009
Posts: 2
Rep:
|
problem in getting output
I am new to ubuntu. was writing a cpp program in vi editor(i suppose d editor is not dat important though), but as i put the command for output, it said permission denied... i tried out crtain things that i am pasting here.. even that didnot work.. I have no ida whatsoever
sanchita@sanchita-desktop:~$ ./unary_op_overload.cpp
bash: ./unary_op_overload.cpp: Permission denied
sanchita@sanchita-desktop:~$ strace -e trace=file./unary_op_overload.cpp
strace: invalid system call `file./unary_op_overload.cpp'
sanchita@sanchita-desktop:~$ strace -e trace=file ./unary_op_overload.cpp
execve("./unary_op_overload.cpp", ["./unary_op_overload.cpp"], [/* 36 vars */]) = -1 EACCES (Permission denied)
strace: exec: Permission denied
Process 7807 detached
sanchita@sanchita-desktop:~$ grep -i exec /etc/fstab
/dev/scd0 /media/cdrom0 udf,iso9660 user,noauto,exec,utf8 0 0
|
|
|
02-19-2009, 07:58 AM
|
#14
|
Senior Member
Registered: Jun 2006
Location: Maryland
Distribution: Kubuntu, Fedora, RHEL
Posts: 1,541
|
Sanchi
You need to compile/link your application before you can run it. Maybe you already have?
Code:
g++ unary_op_overload.cpp -o unary_op_overload
./unary_op_overload
Note the when running the program, the .cpp extension is not used.
P.S. The -o option instructs the GCC (g++) linker what to name the executable program. Change the name to something else if you wish. If you do not specify the -o option, the executable program will be named a.out.
|
|
|
02-20-2009, 05:50 AM
|
#15
|
LQ Newbie
Registered: Feb 2009
Posts: 2
Rep:
|
dwhitney67
thanks for the post... it worked!
wel i had compiled it earlier and then executed ofcourse. wel couldnot understand 1 little part in dis... i had tried ./a.out as well. and if -o is not utilized, ./a.out should give the result, which didnot occur so.. can you please explain me this?
thanks anyway, it worked.
|
|
|
All times are GMT -5. The time now is 06:17 AM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|