This is piece of expect code with mistakes. In a few words, I must connect to the first server, and then jump on the second server, make su - to enable changing the data on this server, all using expect.
spawn ssh -J root@$GATEWAY_ADDRESS litp-admin@$HOST_ADDRESS
expect "assword: "
send "12shroot\r"
expect "assword: "
send "12shroot\r"
expect "~]$ "
send "su -\r"
expect "~assword:"
send "12shroot\r"
send "date -s $NEW_DATE_TIME\r"
What are the possible solutions or examples?
I have not found the right solution.