问题描述
我有一个脚本,可以调用其他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的情况下运行时权限被拒绝的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!