I am trying to run the below shell script:
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"
I am getting the output as:
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
The python file is executing for only 1st command. If run it individually via terminal, it is giving me output, but not from shells script. How do I make same python script run multiple time in shell script?
CodePudding user response:
The shell is looking in the PATH environment variable for the python interpreter. PATH is a very special environment variable. In step one you are replacing the PATH environment variable with the output of python getvar.py path
I would do the following:
- Do you really want to use the special variable "PATH"?
- If so, ensure that
python getvar.py path
includes the path to the python interpreter - Or save the path to the Python interpreter before you change the PATH variable
I would suggest you change your script as follows:
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"