通过 bash 启动 python 脚本时权限被拒绝
# ./scripts/replace-md5sums.py
bash: ./scripts/replace-md5sums.py: Permission denied
replace-md5sums.py
具有 chmod 600
# ls -l ./scripts/replace-md5sums.py
-rw------- 1 ubuntu ubuntu 661 2011-04-27 16:30 ./scripts/replace-md5sums.py
# ./scripts/replace-md5sums.py
bash: ./scripts/replace-md5sums.py: Permission denied
replace-md5sums.py
has chmod 600
# ls -l ./scripts/replace-md5sums.py
-rw------- 1 ubuntu ubuntu 661 2011-04-27 16:30 ./scripts/replace-md5sums.py
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
您应该能够运行脚本,输入:
有时,您当前登录的用户没有更改文件模式位的权限。在这种情况下,如果您有 root 密码,则可以通过以下方式更改文件权限:
You should be able to run the script typing:
There are times where the user you are currently logged with just don't have the permission to change file mode bits. In such cases if you have the root password you can change the file permission this way:
使用“exec”选项挂载 Windows 分区 - 在某些发行版上默认为“noexec”。
Mount your Windows partition with "exec" option - on some distros it's "noexec" by default.
我解决了我的问题。它只是解释器从第一行读取的 python 版本。删除版本号对我来说是这样,即
I solved my problem. it's just the version of python which the interpreter reads off the first line. removing to version numbers did it for me, i.e.
试试这个
Try this
我是 Ubuntu 用户,当我尝试通过 bash 脚本运行 python 脚本而文件位于 NTFS 分区中时(即使使用 su 也不起作用),我也遇到了同样的问题我把它移回家(ext4)然后它就工作了。
I'm a Ubuntu user and I had the same issue, when I was trying to run python script through a bash script while files were located in a NTFS partition (even with su didn't work) then I've moved it home (ext4) then it worked.
好的,首先检查您的 python 脚本是否位于正确的目录中。
在网上,他们说运行命令:
但它不起作用。
然而对我有用的是:
Okay, so first of all check if you are in the correct directory where your python script is located.
On the net, they say to run the command :
But it doesn't work.
What worked for me however was:
检查身份证。它可能具有 root 权限。
因此,输入
su
,然后执行脚本./scripts/replace-md5sums.py
。有用。
Check for id. It may have root permissions.
So type
su
and then execute the script as./scripts/replace-md5sums.py
.It works.