I have a written an except script to ssh to different servers and change .bash_profiles. In my code, i am facing issue with sed command and getting below error.
extra characters after close-quote while executing "send "sed -i '/TERM/a \COL_YELLOW="$(tput setaf 3)"' .bash_profile_backup\r" expect eof"
I tried with all the combination, but its not working. I know its a small indentation issue. If someone could please help with the code.
OS - RHEL6.2.
Code
for server in $(cat temp.lst);
do
{
expect -c "
spawn ssh -t -t "nmehta\@$server"
expect "?assword:"
send \"$password\r\"
send \"\r\"
expect "?nmehta@?"
send \"sudo -u oracle -i\r\"
sleep 5
expect "?assword:"
send \"$password\r\"
sleep 5
send \"cp .bash_profile .bash_profile_backup\r\"
send \"sed -i.bck 's/vt100/xterm/g' .bash_profile_backup\r\"
send \"sed -i '/TERM/a \COL_YELLOW=\"\$(tput setaf 3)\"' .bash_profile_backup\r\"
send \"sed -i '/TERM/a \COL_END="$(tput sgr0 1)"' .bash_profile_backup\r\"
expect eof"
}
done
Trying different indentation I finally was able to execute the script as below.