Schedule an automatic FTP upload on Windows with WinSCP

风格不统一 提交于 2019-12-01 11:35:00

问题


Let me preface this with a disclaimer, I have never executed scripts on the UI of WinSCP.

I have a program on our server that generates a text file that I want to be sent to our organization's shared drive. While looking through the internet I came across a few solutions, such as the code below. (Credentials have been left out for obvious reasons)

option batch abort
option confirm off
open ftp://user:pass@server
synchronize local U:\DO Unitization\Team Member Folders\xxxxxxxx
exit

This is then saved as a .txt (abc.txt)

Then executed manually as winscp.com /script=abc.txt

This is not what I want, seeing as thought the whole purpose was to automate this. Also, only one file actually needs to be sent, not everything in the directory. As I said above, my knowledge is lacking in this area so I apologize for any miscommunication.

Thank you, Joshua Averbuch


回答1:


For a start, see WinSCP guide to automating file transfers to FTP server.

A simple batch file (upload.bat) to upload a file to FTP server with WinSCP looks like:

winscp.com /log=c:\path\ftp.log /command ^
    "open ftp://user:password@example.com/" ^
    "put ""U:\DO Unitization\Team Member Folders\xxxxxxxx\file.txt"" ""/remote/path/""" ^
    "exit"

You can have the batch file generated by WinSCP GUI for you.


For scheduling, simply use the Windows Scheduler.
For details see another WinSCP guide to scheduling file transfers to FTP server.



来源:https://stackoverflow.com/questions/47534703/schedule-an-automatic-ftp-upload-on-windows-with-winscp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!