I am trying to write a script that will log in to all of the systems and change the password. I have the entire script written but the only problem is I use the "read" command in the script like so:
the only problem is that when I use the "PASSWORD" variable later on in the script it will not put in the password correctly because there are symbols in my password. Such as "$" and it will then think that everything after that symbol is a variable. Is there some way to force it to not do anything with the symbols in my password.
below you will see the script I am a tempting to change my passwd. Assume that the variables are correct.:
Code:
echo -n "Please type your current password: "
read -s OLDPASSWD
echo ""
echo -n "Please type your new password: "
read -s NEWPASSWD
echo ""
for SERVER in ${softwareforge}; do
/usr/bin/expect << EOF
spawn ssh -t ${USERNAME}@${SERVER}
expect "*?assword: "
send "${CURRENTPASSWD=}\n"
expect "*]$ "
send "passwd\n"
expect "*?assword: "
send "${OLDPASSWD}\n"
expect "*?assword: "
send "${NEWPASSWD}\n"
expect "*?assword: "
send "${NEWPASSWD}\n"
EOF
done