In the following expect script, I noticed that the script will send the password even before prompted for the password. How can this be prevented? Could I use a wait statement or something?
#!/usr/bin/expect -f
#set timeout 25
spawn rsync root@14.12.123.82:'/usr/backups /usr/backup-scripts /root/test/' /root/
expect "root@14.12.123.82's password: $"
send "\$xxxxxx\n"
expect "\\$ $