【发布时间】:2016-07-14 17:37:10
【问题描述】:
我有一个这样的简单脚本。
#!/bin/bash
scl enable python33 bash
args=$#
if [[ $args -eq 1 ]]; then
python script.py
fi
我使用bash myscript foo 之类的命令运行脚本,但在上面的当前代码中,只有命令会运行scl enable python33 bash,并且由于某种原因下一个 if 块不会被执行,但如果我删除了 @ 行987654324@ 然后 if 块中的代码可以毫无问题地执行。
起初我认为scl enable python33 bash 导致脚本退出,但事实并非如此,因为我可以在运行脚本之前和之后看到python -V,它按预期工作而没有错误。
由于某种原因,scl enable python33 bash 命令和 if 块似乎不属于脚本。
【问题讨论】:
-
scl命令有什么作用? -
@AvihooMamka 我有 python
2.7,默认情况下与 CentOs7 一起提供。所以,我安装了 python 3.3 并且scl enable python33 bash使 python3.3 成为机器中的默认值,因为我的python script.py你在问题中看到的那个只能与 python 3.3 一起运行 -
为什么不直接从其位置运行
python3?例如:/usr/bin/python3.3 script.py? -
由于某种原因,我的位于
/opt/rh/python33/root/usr/bin/python3.3,但我想使用python foo.py,因为如果我运行 scl 命令我可以使用 python,我不知道为什么这个 shell 命令不是工作。 -
@ANW 你不能提供python33的完整路径而不是在shell脚本中只写“python”吗?
标签: linux bash python-2.7 shell python-3.x