WinSCP - How to recognize if file was transferred successfully

。_饼干妹妹 提交于 2019-12-01 11:45:46

Quoting WinSCP FAQ How do I know that script completed successfully?:

You can tell the result of script by WinSCP exit code. Code 0 indicates success, while 1 indicates an error. For more details refer to scripting documentation.

Batch script (specified using /script or /command command-line switches) terminates with code 1 immediately once any error occurs. You can change this using option batch command.

To find out why the script failed, inspect session log.

For an example see a guide to transfer automation or the example on retrying s/connection attempt.

If you need a better control of error handling, consider using WinSCP .NET assembly instead (e.g. from a PowerShell script).

WinSCP has an option to log all your operations into an XML log. you can then analyze the log to know exactly what happened during the session.

Below,is the batch file I use to accomplish a sync from an ftp server to a local directory, deleting any changes on the local side.The batch file also saves a XML log of all transfers.

@echo off
cd %programfiles(x86)%\winscp\
start /b winscp.exe /log="C:\Sync\logs\!M-!D-!Y@!T.xml" /xmlgroups /command "open   ftp://username:password@ftp.foo.com" "synchronize local -delete -criteria=size     ""C:\Users\jdoe\Documents\Synced Docs"" / 

The parameter that you will want to play with is the "winscp.exe /log="C:\Sync\logs!M-!D-!Y@!T.xml" /xmlgroups"

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