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 |
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> Cheers. |
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 |
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 |
It looks like you may not have permission to run/call exec.. I'll do some testing and get back to you..
Cheers. |
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 |
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? |
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. |
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.
|
i just removed the user option and that fixed it. thanks a lot bastard23 et al. for the help.
|
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 |
Thank you very much -- had the same problem here. This was pretty difficult to track down...
|
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 |
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 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. |
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 07:50 PM. |