今天运维突然过来叫我帮忙写个.bat脚本,用上传备份文件到指定的FTP服务器上,bat又叫批处理文件,完全没写过bat,倒是在破解文件或一些外挂的软件见过不少bat脚本,分享一下这一次的成果。
上传命名为上传日期的文件到ftp服务器上
@echo off
set bak=%date:~0,4%%date:~5,2%%date:~8,2%
set "bak=%bak: =%"
set ftpUser=XXXX
set ftpPass=XXXX
set ftpIP=192.168.XXX.XXX
echo open %ftpIp%>a.txt
echo %ftpUser%>>a.txt
echo %ftpPass%>>a.txt
echo put %bak%.bak>>a.txt
echo bye>>a.txt
ftp -s:a.txt
pause
del a.txt /q
上传文件前缀是上传日期的文件去ftp服务器
@echo off
set bak=%date:~0,4%%date:~5,2%%date:~8,2%
set "bak=%bak: =%"
set ftpUser=XXXX
set ftpPass=XXXX
set ftpIP=192.168.XXX.XXX
echo open %ftpIp%>a.txt
echo %ftpUser%>>a.txt
echo %ftpPass%>>a.txt
echo mput %bak%*.bak>>a.txt
echo bye>>a.txt
ftp -v -i -s:a.txt
pause
del a.txt /q