scpUpdate.sh 462 B

123456789101112131415161718192021222324
  1. #!/bin/bash
  2. Ip="was.baoshi56.com"
  3. username="baoshi"
  4. password="bAOSHI123!"
  5. update_path=/var/www/update
  6. dsc=/var/www/was
  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
  20. sudo chmod 775 $dsc/* -R