简体   繁体   中英

Permission denied error message

Can't execute a C-program I wrote although I have read, write and execute permissions for it.

Getting the following error message:

 -bash: ./program_name: Permission denied

What is going on here? Anybody has a clue?

UPDATE: I did not have execution permission for the binary file ... I have now changed the user rights for the binary file: Here's the result of the command ls -l program_name:

-rwxr--r--@ 1 my_username  staff  2284 Jan 14 21:26 program_name

I now get the following error message when trying to run the file: -

bash:./program_name: cannot execute binary file

I would bet that you don't, in fact, have execute permission for it.

Check the permissions with:

ls -l ./program_name

Update your question with the output so we/I can cross check your conclusion.

Update : The output appears that you have execute permission on the source file ( .c gives me that impression). This will not work.

You need to compile C programs (usually with gcc on Linux, xcode 1 on Mac). If you did and everything is successful, you get a new file. Usually, without an extension. That is the executable and that is what needs the permissions.

So, assuming the executable is program_name without .c give it a try again.

1 I think XCode uses GCC too

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM