I have an existing python code and i need to call a bash script from inside. The python code captures few variables and i need this to be passed to my shell to avoid duplicate input from user.
I have created a test script to simulate this, however, i am not able to echo the variables in shell ( it retuns a null )
1): Is it possible to pass the python variable to the shell script being called using subprocess? 2) If the below code can be optimized to achieve this, i am open to feedback.
Python code:
import os import subprocess first=input("Enter the first ip") second=input("Enter the second IP") subprocess.call(['bash','./script.sh',first,second])
Bash code (script.sh):
#!/bin/bash ########################### echo "The First IP is $first" echo "Enter your server " read faulty_server echo "The server is $faulty_server"