简体   繁体   English

权限被拒绝错误消息

[英]Permission denied error message

Can't execute a C-program I wrote although I have read, write and execute permissions for it.尽管我拥有读取、写入和执行权限,但无法执行我编写的 C 程序。

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:更新:我没有二进制文件的执行权限......我现在已经更改了二进制文件的用户权限:这是命令 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).更新:输出显示您对源文件具有执行权限( .c给了我这种印象)。 This will not work.这是行不通的。

You need to compile C programs (usually with gcc on Linux, xcode 1 on Mac).您需要编译 C 程序(通常在 Linux 上使用 gcc,在 Mac 上使用 xcode 1 )。 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.因此,假设可执行文件是没有.c program_name再试一次。

1 I think XCode uses GCC too 1我认为 XCode 也使用 GCC

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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