First, please forgive me for my inexperience.
I am trying to create a script that upgrades multiple machines through ssh, and I am receiving errors, primarily "upgrade-all.sh: 7: Bad substitution"
The original script that I am trying to modify mine from is found from Arjun G's answer from post text
My script is:
#!/bin/bash
USERNAMES="jed", "root", "cord"
HOSTS="***.***.***.***", "***.***.***.***", "***.***.***.***"
PASSWORDS="***", "***", "***"
SCRIPT="pwd; echo -e 'PASSWORD' | sudo apt update | sudo apt upgrade -y && sudo apt autoremove -y"
for i in ${!HOSTS[@]} ; do
echo ${HOSTS[i]}
SCR=${SCRIPT/PASSWORD/${PASSWORDS[i]}}
sshpass -p ${PASSWORDS[i]} ssh -l ${USERNAMES[i]} ${HOSTS[i]} "${SCR}"
done
I tried swapping variables in ${!HOSTS[@]}, but it did not clear up the error. I have found myself out of my depth to make educated guess with substitutions.
Thanks for any help!
root,is not a valid command.ansiblewhich is designed for this kind of thing.