在windows上实现ftp的数据推送
可以分成两个文件,一个bat,一个txt。
bat直接调用ftp命令并用-s参数指定配置文件
@echo off ftp -s:C:UsersAdministratorDesktopscriptsauto_stationauto_station_all.txt
txt文件配置的是ftp的操作命令
open 10.12.13.20 ftp_user 123456 prompt off lcd D:smodataset广东59288AWS新型自动站设备Hour cd /qxgcy/devices/Hour mput * close open 10.12.13.20 ftp_user 123456 lcd D:smodataset广东59288AWS新型自动站设备Minute cd /qxgcy/devices/Minute mput * close open 10.12.13.20 ftp_user 123456 lcd D:smodataset广东59288AWS新型自动站设备状态 cd /qxgcy/devices/status mput * prompt on bye quit
也可以把这两步都写在同一个bat下
@echo off set date1=%Date:~0,4%%Date:~5,2% #bat输出时间的方式,其中Date是命令,%Date:~0,4%代表指针向右偏移0位,同时向右抓取4个字符。 set date2=%Date:~0,4%%Date:~5,2%%Date:~8,2% (echo open 10.12.13.20 echo ftp_user echo 123456 echo prompt off echo lcd D:smodataset广东59288AWS新型自动站设备Hour echo cd /qxgcy/devices/Hour echo mput *%date1%*.txt echo lcd D:smodataset广东59288AWS新型自动站设备Minute echo cd /qxgcy/devices/Minute echo mput *%date2%*.txt echo lcd D:smodataset广东59288AWS新型自动站设备状态 echo cd /qxgcy/devices/status echo mput *%date2%*.txt echo prompt on echo quit) > C:UsersAdministratorDesktopscriptsauto_stationauto_station_add.txt ftp -s:C:UsersAdministratorDesktopscriptsauto_stationauto_station_add.txt