On my Windows 10 system, I have a BAT script that utilizes winscp.com to transfer a single file to an SFTP server on the internet. The script records the outcome of the transfer in an XML file.
<?xml version="1.0" encoding="UTF-8"?>
<session xmlns="http://winscp.net/schema/session/1.0" name="[email protected]" start="2020-02-08T10:04:41.012Z">
<upload>
<filename value="c:\sftp\test.txt" />
<destination value="/Data/test.txt" />
<result success="true" />
</upload>
<touch>
<filename value="/Data/test.txt" />
<modification value="2020-02-08T03:52:28.000Z" />
<result success="true" />
</touch>
</session>
When the transfer of a single file is successful, the output in the log file shows two elements: “upload” and “touch,” both of which have a value of “success = true.”
To verify if the transfer was successful, I am unsure of the meaning of “upload” and “touch” and whether both elements need to have a value of “true” for the transfer to be considered successful. Although I could manually download the file to check its integrity, I would prefer not to. The first parameter of my winscp.com command is the script file, and the second is the XML log file, which is specified as /xmllog=”C:\SFTP\mylog.xml”.
As a beginner in this area, I apologize if my query is too basic.
3 Answers
It’s not necessary to analyze the XML log to confirm the success of the transfer. You can just check the WinSCP exit code. If the transfer was successful, the exit code returned by WinSCP will be 0, otherwise it will be 1.
The WinSCP FAQ may provide additional information on this topic. How do I know that script completed successfully?