How to use expect
Please help me with the expect utility.
I need to scp some files to a remote server. I have the script below:
set myhost 10.10.1.43
spawn scp -pr /root/temp/ $myhost:/usr/local/inventory
This script works if the password is correct and the server is running. The problem is how to care of the following:
1. When the password is wrong, the program stops and does not timeout because another prompt appears and it is wating user input.
2. When the remote server is down/hanging, the program also hangs and does not timeout.
How can I fix this? Please help.