I have an expect script to SSH to a remote host and obtain some user inputs and information about the server/network configuration. The responses are saved in a text file that I then need to copy to my local host so that I can read the lines into variables for use in the parent shell script.
Is there a way to do this without needing to enter the username and password for the local host to use function scp? I have tried the following in my expect script to no avail:
Code:
spawn scp $usr@$host:$flnm .
expect {
-re "(.*)assword:" {
send -s "$pswd\r"
}
}
I have also tried to directly scp the file and enter the username and password to try to debug the issue, and that doesn't work either:
Code:
spawn scp file.txt user@host:file.txt
expect {
-re "(.*)assword:" {
send -s "password\r"
}
"you sure you want to continue connecting" {
send -s "yes\r"
exp_continue
}
}
In both scenarios I have used exp_internal 1, and there are no errors. But I do not end up with the file on my local host.
Following the copy, I would like to delete the file from the remote host. Any suggestions on how to accomplish this?