下载 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!"