scp_cmd.exp 304 B

123456789101112131415
  1. #!/usr/bin/expect -f
  2. set timeout -1
  3. set host [lindex $argv 0]
  4. set password [lindex $argv 1]
  5. set source [lindex $argv 2]
  6. set dest [lindex $argv 3]
  7. spawn scp -r -o StrictHostKeyChecking=no $source root@$host:$dest
  8. expect {
  9. "password:" {
  10. send "$password\r"
  11. exp_continue
  12. }
  13. eof
  14. }