windows 遠端下載sftp 伺服器 檔案
阿新 • • 發佈:2019-08-21
下載 putty
https://www.chiark.greenend.org.uk/~sgtatham/putty/latest.html
把安裝後的 psftp.exe 放到需要下載檔案的目錄
嘗試執行遠端連線
執行 psftp.exe
open : 111:111:111:111
錄入賬號密碼
help 顯示可執行語句
嘗試下載檔案
編寫
Download_Start.bat
psftp -l root -pw 7EiwLGiYYX < Download_cmd.txt
exit
Download_cmd.txt
open 122.152.212.111
cd /usr/mysql-backup
get a.xlsx
bye
由於找不到如何編寫變數,改用sh
建立
download.sh
#!/bin/sh
HOST=122.152.212.111
USER=root
PASSWORD=7EiwLGiYYX
LOCAL_PATH=C:\Users\donald\Desktop\down
REMOTE_PATH=/usr/mysql-backup
d2=`date +%Y%m%d`
FILENAME="zita_wms-"$d2"_013001.dump"
psftp -l root -pw 7EiwLGiYYX << EOM
open 122.152.212.111
lcd $LOCAL_PATH
cd $REMOTE_PATH
get $FILENAME
bye
EOM
echo "Success!"