Reputation: 12122
How can we copy the files recursively to the remote server using expect script or any other script?.
Constraints.
1. We couldn't limit the number of file will be copied.
2. File size may be 1mb or upto 10mb.
I was tried with the following script. But it's only transfer upto 4 or 5 files only. (I need to transfer files, nearly 200 or 300 above)
spawn scp -r /home/test [email protected]:/home/test
sleep 2
expect "password"
send "XXXXXX"
sleep 2
Upvotes: 0
Views: 2153
Reputation: 247092
Before the spawn
command, add the line
set timeout -1
and replace the 2nd sleep
command with
expect eof
Don't forget to add \r
when you send your password: send "password\r"
I'd recommend you set up SSH keys -- then you won't be prompted for a password and you don't need the expect script at all.
Upvotes: 3