I need to pass a list of strings from python to shell script.
Goal: Inside the Shell script,
1)The shell script should accept that list of strings which is passed as a parameter.
2)I need to loop that list and print the strings inside the loop.
What I had tried:
main.py
import subprocess
ssh_key_path = #KEY_PATH
ip_address = #BASTION_IP
Details = #Somedata
list_1 = ["apple","banana","carrot"]
script = subprocess.call([sh,fruits.sh,ssh_key_path,ip_address,Details,list_1])
fruits.sh
ssh -i $1 ubuntu@$2 -o StrictHostKeyChecking=no << EOF
printf $3 >/home/Details.txt
fruits = $4
for i in $4; do
echo "$i"
done
echo "Success"
EOF
Output from fruits.sh:(Expected Output)
apple
banana
carrot
Success
Error: expected str, bytes, or os.PathLike object, not list.
So,How to pass the list to shell script and execute inside it.?