I am trying to move/copy some files from my local machine to another host which I am able to access via ssh. But unfortunately this below script is not working.when I run this script it is asking me Are you sure you want to continue connecting (yes/no)? every time I run it.I have 3 file file on my local machine ranfull ranhalf midran which I need to transfer/copy it to other host via scp script, but only the first file is getting copied. It won't be possible to set sshkeygen.#!/bin/bashHOSTS=VM2 VM3 VM4 VM1read -p Password:  PASSWORDfor HOST in $HOSTSdoexpect -c spawn /usr/bin/scp /tmp/ranfull ranhalf midran root@$HOST:/tmp/expect {*password:* { send $PASSWORD\r;interact }}exitdone
Expect script for copying file
shell script;scripting;expect
First, your quoting is suspect: you have double quotes in a double quoted string. Let's fix that, and improve the indentation:for HOST in $HOSTS; do    expect -c <<END_EXPECT        spawn /usr/bin/scp /tmp/ranfull ranhalf midran root@$HOST:/tmp/        expect {            *password:* {                send $PASSWORD\r                interact            }        }        exitEND_EXPECTdoneNow, to accomodate a prompt that may or may not appear, with expect you do this:        expect {            Are you sure you want to continue connecting* {                send yes\r                exp_continue            }            *password:* {                send $PASSWORD\r                interact            }        }exp_continue essentially loops back to the expect command so it can still watch for another Are you sure... prompt or the password prompt.