scpUpdate.sh 433 B

12345678910111213141516171819202122
  1. #!/bin/bash
  2. Ip="was.baoshi56.com"
  3. username="haozi"
  4. password="haozi"
  5. update_path=/var/www/update
  6. dsc=/var/www/update
  7. # shellcheck disable=SC2045
  8. # shellcheck disable=SC2034
  9. # shellcheck disable=SC2006
  10. for file in `ls $update_path`
  11. do
  12. expect -c "
  13. spawn scp -P 10022 -r $update_path/$file $username@$Ip:$dsc
  14. expect {
  15. \"*assword\" {set timeout 120; send \"$password\r\";}
  16. \"yes/no\" {send \"yes\r\"; exp_continue;}
  17. }
  18. expect eof"
  19. done