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 tr开发者_如何学Pythonied 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 root@example.com:/home/test
sleep 2
expect "password"
send "XXXXXX"
sleep 2
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.
精彩评论