在没有bash的情况下运行时权限被拒绝

编程入门 行业动态 更新时间:2024-10-26 00:31:39
本文介绍了在没有bash的情况下运行时权限被拒绝的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有一个脚本,可以调用其他bash,python和ruby脚本.该脚本类似于以下内容:

I have a script which calls some other bash, python, and ruby scripts. The script is similar to the following:

#!/bin/bash set -x ./aux1.py ./aux2.sh

当我从命令行运行脚本时,它会运行,但是会提供以下输出:

When I run the script from the command line, it runs but it gives me the following output:

./script.sh: line 5: ./aux1.py: Permission denied

aux.py 脚本的顶部具有#!/usr/bin/env python ;当我使用 ./aux.py 从命令行调用它时,这很好,但是以完全相同的方式从该脚本中调用时,我会收到此错误.奇怪的是,只有当我使用 ./script.sh 运行脚本时,才会发生这种情况.当我使用 bash script.sh 运行脚本时,辅助脚本可以完美运行.

The aux.py script has #!/usr/bin/env python at the top; when I call it from the command line with ./aux.py it is fine, however when called from this script in the exact same way I get this error. The strange part is that this only happens when I run the script with ./script.sh; when I run the script with bash script.sh the auxilliary scripts work perfectly.

我正在使用Linux,为什么会这样?

I'm using Linux, why does this happen?

更新,2014年3月3日

PATH 中没有任何冲突,并且所有脚本都是chmod + rx . uname -srvmo 提供

There's nothing conflicting in the PATH, and all of the scripts are chmod +rx. uname -srvmo gives

Linux 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Dec 13 06:58:20 EST 2013 x86_64 GNU/Linux

, uname -a 中没有更多可用信息.SELinux已启用,但我不是管理员,所以我无法访问该信息.

and there's no more information available in uname -a. SELinux is enabled, but I'm not an administrator so I can't access that information.

推荐答案

也许在运行脚本之前输入 sudo su ,以便您成为 root 用户.脚本完成后,只需键入 exit 即可退出根目录.再次键入 exit 关闭外壳.

Maybe type sudo su before running your script so that you are the root user. When the script completes simply type exit to get out of root. Type exit again to close the shell.

:D

更多推荐

在没有bash的情况下运行时权限被拒绝

本文发布于:2023-11-06 04:00:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1562673.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:被拒   情况下   权限   bash

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!