#!/bin/bash Ip="was.baoshi56.com" username="baoshi" password="bAOSHI123!" update_path=/var/www/update dsc=/var/www/was # shellcheck disable=SC2045 # shellcheck disable=SC2034 # shellcheck disable=SC2006 for file in `ls $update_path` do expect -c " spawn scp -P 10022 -r $update_path/$file $username@$Ip:$dsc expect { \"*assword\" {set timeout 120; send \"$password\r\";} \"yes/no\" {send \"yes\r\"; exp_continue;} } expect eof" done sudo chmod 775 $dsc/* -R