运行 python 脚本在 shell 脚本中多次
Run python script multiple times inside shell script
我正在尝试 运行 下面的 shell 脚本:
PATH=`python getvar.py path`
PATH_REPO="$PATH/$FOLDER_NAME/"
echo "path repo is $PATH_REPO"
ESP=`python getvar.py esp`
echo "esp is $ESP"
DPLYR=`python getvar.py deployer`
echo "deployer is $DPLYR"
recipients_list=`python getvar.py recipients`
echo "recipient list is $recipients_list"
REMOTE_USER=`python getvar.py remoteuser`
echo "user is $REMOTE_USER"
我得到的输出为:
path repo is /home/developer/user1
./test.sh: line 14: python: command not found
esp is
./test.sh: line 16: python: command not found
deployer is
./test.sh: line 18: python: command not found
recipient list is
./test.sh: line 21: python: command not found
user is
python 文件仅针对第一个命令执行。如果 运行 它单独通过终端,它会给我输出,而不是来自 shells 脚本。
如何在 shell 脚本中多次制作相同的 python 脚本 运行?
shell 正在 PATH 环境变量中查找 python 解释器。 PATH 是一个非常特殊的环境变量。在第一步中,您将 PATH 环境变量替换为 python getvar.py path
的输出
我会做以下事情:
- 您真的要使用特殊变量“PATH”吗?
- 如果是这样,请确保
python getvar.py path
包含 python 解释器的路径
- 或者在更改 PATH 变量之前保存 Python 解释器的路径
我建议您按如下方式更改脚本:
MYPATH=`python getvar.py path`
PATH_REPO="$MYPATH/$FOLDER_NAME/"
echo "path repo is $PATH_REPO"
ESP=`python getvar.py esp`
echo "esp is $ESP"
DPLYR=`python getvar.py deployer`
echo "deployer is $DPLYR"
recipients_list=`python getvar.py recipients`
echo "recipient list is $recipients_list"
REMOTE_USER=`python getvar.py remoteuser`
echo "user is $REMOTE_USER"
我正在尝试 运行 下面的 shell 脚本:
PATH=`python getvar.py path`
PATH_REPO="$PATH/$FOLDER_NAME/"
echo "path repo is $PATH_REPO"
ESP=`python getvar.py esp`
echo "esp is $ESP"
DPLYR=`python getvar.py deployer`
echo "deployer is $DPLYR"
recipients_list=`python getvar.py recipients`
echo "recipient list is $recipients_list"
REMOTE_USER=`python getvar.py remoteuser`
echo "user is $REMOTE_USER"
我得到的输出为:
path repo is /home/developer/user1
./test.sh: line 14: python: command not found
esp is
./test.sh: line 16: python: command not found
deployer is
./test.sh: line 18: python: command not found
recipient list is
./test.sh: line 21: python: command not found
user is
python 文件仅针对第一个命令执行。如果 运行 它单独通过终端,它会给我输出,而不是来自 shells 脚本。 如何在 shell 脚本中多次制作相同的 python 脚本 运行?
shell 正在 PATH 环境变量中查找 python 解释器。 PATH 是一个非常特殊的环境变量。在第一步中,您将 PATH 环境变量替换为 python getvar.py path
我会做以下事情:
- 您真的要使用特殊变量“PATH”吗?
- 如果是这样,请确保
python getvar.py path
包含 python 解释器的路径 - 或者在更改 PATH 变量之前保存 Python 解释器的路径
我建议您按如下方式更改脚本:
MYPATH=`python getvar.py path`
PATH_REPO="$MYPATH/$FOLDER_NAME/"
echo "path repo is $PATH_REPO"
ESP=`python getvar.py esp`
echo "esp is $ESP"
DPLYR=`python getvar.py deployer`
echo "deployer is $DPLYR"
recipients_list=`python getvar.py recipients`
echo "recipient list is $recipients_list"
REMOTE_USER=`python getvar.py remoteuser`
echo "user is $REMOTE_USER"