通過FTP方式上傳資料夾(整個目錄)
阿新 • • 發佈:2019-02-20
可以利用下面的指令碼將資料夾從本地伺服器FTP上傳到遠端伺服器:
#!/bin/bash
#upload dir to remote ftp serverread -p "Input local dir: " updir #local dir
read -p "Input remote dir: " todir #remote dir
read -p "Input remote IP: " ip #remote IP
read -p "Input ftp username: " user #ftp username
read -p "Input password: " password #password
sss=`find $updir -type d -printf $todir/'%P\n'| awk '{if ($0 == "")next;print "mkdir " $0}'`
aaa=`find $updir -type f -printf 'put %p %P \n'`
ftp -nv $ip <<EOF
user $user $password
type binary
prompt
$sss
cd $todir
$aaa
quit
EOF