logging_xml » Revisions »
Differences
This shows you the differences between the selected revisions of the page.
logging_xml 2024-10-03 | logging_xml 2024-12-02 (current) | ||
Line 1: | Line 1: | ||
- | 317 | ||
- | |||
- | |||
====== XML Logging ====== | ====== XML Logging ====== | ||
XML logging is one of the WinSCP [[logging|log formats]]. An %%XML%% log includes structured records describing operations done by WinSCP over session. The log format is protocol independent. | XML logging is one of the WinSCP [[logging|log formats]]. An %%XML%% log includes structured records describing operations done by WinSCP over session. The log format is protocol independent. | ||
Line 22: | Line 19: | ||
An overall format of the %%XML%% log file follows: | An overall format of the %%XML%% log file follows: | ||
- | &lt;code xml&gt; | + | <code xml> |
- | &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; | + | <?xml version="1.0" encoding="UTF-8"?> |
- | &lt;session xmlns=&quot;http://winscp.net/schema/session/1.0&quot; | + | <session xmlns="http://winscp.net/schema/session/1.0" |
- | name=&quot;martin@example.com&quot; start=&quot;2009-03-02T19:34:57.734Z&quot;&gt; | + | name="martin@example.com" start="2009-03-02T19:34:57.734Z"> |
- | &lt;!-- operations --&gt; | + | <!-- operations --> |
- | &lt;/session&gt; | + | </session> |
- | &lt;/code&gt; | + | </code> |
- | The top level ''session'' tag represents one logical session, which may consist of several physical sessions, particularly when connection is lost. Attribute ''name'' refers to name of the logical session. Attribute ''start'' indicates time when the session was initiated.((All timestamps in the %%XML%% log have %%XML%% ''dateTime'' type, where only ''%%YYYY-MM-DD&quot;T&quot;HH:MM:SS.NNN&quot;Z&quot;%%'' syntax is used.)) | + | The top level ''session'' tag represents one logical session, which may consist of several physical sessions, particularly when connection is lost. Attribute ''name'' refers to name of the logical session. Attribute ''start'' indicates time when the session was initiated.((All timestamps in the %%XML%% log have %%XML%% ''dateTime'' type, where only ''%%YYYY-MM-DD"T"HH:MM:SS.NNN"Z"%%'' syntax is used.)) |
The ''session'' element includes [[#elements|child elements]], where each element represents single log entry, i.e. single physical operation with remote file over the logical session. | The ''session'' element includes [[#elements|child elements]], where each element represents single log entry, i.e. single physical operation with remote file over the logical session. | ||
Line 46: | Line 43: | ||
Result of a specific operation is represented by child ''result'' element of respective operation element. The ''result'' element has boolean ''success'' attribute. | Result of a specific operation is represented by child ''result'' element of respective operation element. The ''result'' element has boolean ''success'' attribute. | ||
- | &lt;code xml&gt; | + | <code xml> |
- | &lt;result success=&quot;true&quot; /&gt; | + | <result success="true" /> |
- | &lt;/code&gt; | + | </code> |
If ''success'' is ''false'', ''result'' element will typically include one or more ''message'' elements with error message(s). The error message is free text, that may be language-, protocol- or even server-specific. So you should not try to process it automatically. | If ''success'' is ''false'', ''result'' element will typically include one or more ''message'' elements with error message(s). The error message is free text, that may be language-, protocol- or even server-specific. So you should not try to process it automatically. | ||
The following example is from English version, connected with SFTP protocol to OpenSSH server: | The following example is from English version, connected with SFTP protocol to OpenSSH server: | ||
- | &lt;code xml&gt; | + | <code xml> |
- | &lt;result success=&quot;false&quot;&gt; | + | <result success="false"> |
- | &lt;message&gt;Cannot open remote file '/home/user/examplefile.txt'.&lt;/message&gt; | + | <message>Cannot open remote file '/home/user/examplefile.txt'.</message> |
- | &lt;message&gt;No such file or directory. | + | <message>No such file or directory. |
Error code: 2 | Error code: 2 | ||
Error message from server: No such file | Error message from server: No such file | ||
- | Request code: 3&lt;/message&gt; | + | Request code: 3</message> |
- | &lt;/result&gt; | + | </result> |
- | &lt;/code&gt; | + | </code> |
With some protocols, each of the physical operations are performed individually. With some protocols, set of operations may be performed in atomic form. This may prevent mapping error to specific operation. In this case the error may be associated with more operations, resulting in its duplication in the %%XML%% log. | With some protocols, each of the physical operations are performed individually. With some protocols, set of operations may be performed in atomic form. This may prevent mapping error to specific operation. In this case the error may be associated with more operations, resulting in its duplication in the %%XML%% log. | ||
Line 74: | Line 71: | ||
If the particular error was associated with a physical operation, the error message will be included both in ''result'' child element of the respective operation element and in ''failure'' child element of top level ''session'' element or ''group'' element. | If the particular error was associated with a physical operation, the error message will be included both in ''result'' child element of the respective operation element and in ''failure'' child element of top level ''session'' element or ''group'' element. | ||
- | &lt;code xml&gt; | + | <code xml> |
- | &lt;upload&gt; | + | <upload> |
- | &lt;filename value=&quot;d:\examplefile.txt&quot; /&gt; | + | <filename value="d:\examplefile.txt" /> |
- | &lt;result success=&quot;false&quot;&gt; | + | <result success="false"> |
- | &lt;message&gt;Cannot create remote file '/home/user/examplefile.txt'.&lt;/message&gt; | + | <message>Cannot create remote file '/home/user/examplefile.txt'.</message> |
- | &lt;message&gt;Permission denied. | + | <message>Permission denied. |
Error code: 3 | Error code: 3 | ||
Error message from server: Permission denied | Error message from server: Permission denied | ||
- | Request code: 3&lt;/message&gt; | + | Request code: 3</message> |
- | &lt;/result&gt; | + | </result> |
- | &lt;/upload&gt; | + | </upload> |
- | &lt;failure&gt; | + | <failure> |
- | &lt;message&gt;Cannot create remote file '/home/user/examplefile.txt'.&lt;/message&gt; | + | <message>Cannot create remote file '/home/user/examplefile.txt'.</message> |
- | &lt;message&gt;Permission denied. | + | <message>Permission denied. |
Error code: 3 | Error code: 3 | ||
Error message from server: Permission denied | Error message from server: Permission denied | ||
- | Request code: 3&lt;/message&gt; | + | Request code: 3</message> |
- | &lt;/failure&gt; | + | </failure> |
- | &lt;/code&gt; | + | </code> |
===== [[group]] Grouping Operations for Commands ===== | ===== [[group]] Grouping Operations for Commands ===== | ||
When using the %%XML%% logging together with [[scripting|scripting]], [[#elements|operations]] and [[#result_script|failures]] belonging to the same command can be grouped using parent ''group'' element: | When using the %%XML%% logging together with [[scripting|scripting]], [[#elements|operations]] and [[#result_script|failures]] belonging to the same command can be grouped using parent ''group'' element: | ||
- | &lt;code xml&gt; | + | <code xml> |
- | &lt;group name=&quot;put -preservetime d:\*.txt&quot; start=&quot;2021-12-03T14:25:10.204Z&quot;&gt; | + | <group name="put -preservetime d:\*.txt" start="2021-12-03T14:25:10.204Z"> |
- | &lt;upload&gt; | + | <upload> |
- | &lt;filename value=&quot;d:\readme.txt&quot; /&gt; | + | <filename value="d:\readme.txt" /> |
- | &lt;destination value=&quot;/home/user/readme.txt&quot; /&gt; | + | <destination value="/home/user/readme.txt" /> |
- | &lt;size value=&quot;15345&quot; /&gt; | + | <size value="15345" /> |
- | &lt;result success=&quot;true&quot; /&gt; | + | <result success="true" /> |
- | &lt;/upload&gt; | + | </upload> |
- | &lt;upload&gt; | + | <upload> |
- | &lt;filename value=&quot;d:\examplefile.txt&quot; /&gt; | + | <filename value="d:\examplefile.txt" /> |
- | &lt;result success=&quot;false&quot;&gt; | + | <result success="false"> |
- | &lt;message&gt;Cannot create remote file '/home/user/examplefile.txt'.&lt;/message&gt; | + | <message>Cannot create remote file '/home/user/examplefile.txt'.</message> |
- | &lt;message&gt;Permission denied. | + | <message>Permission denied. |
Error code: 3 | Error code: 3 | ||
Error message from server: Permission denied | Error message from server: Permission denied | ||
- | Request code: 3&lt;/message&gt; | + | Request code: 3</message> |
- | &lt;/result&gt; | + | </result> |
- | &lt;/upload&gt; | + | </upload> |
- | &lt;failure&gt; | + | <failure> |
- | &lt;message&gt;Cannot create remote file '/home/user/examplefile.txt'.&lt;/message&gt; | + | <message>Cannot create remote file '/home/user/examplefile.txt'.</message> |
- | &lt;message&gt;Permission denied. | + | <message>Permission denied. |
Error code: 3 | Error code: 3 | ||
Error message from server: Permission denied | Error message from server: Permission denied | ||
- | Request code: 3&lt;/message&gt; | + | Request code: 3</message> |
- | &lt;/failure&gt; | + | </failure> |
- | &lt;/group&gt; | + | </group> |
- | &lt;/code&gt; | + | </code> |
Grouping can be enabled on [[commandline#scripting|command-line]]. | Grouping can be enabled on [[commandline#scripting|command-line]]. | ||
- | //Grouping is particularly useful, when you are [[guide_interpreting_xml_log#continuous|continuously reading the XML log file]]. By receiving ''&lt;/group&gt;'' you know that the command execution has finished.// | + | //Grouping is particularly useful, when you are [[guide_interpreting_xml_log#continuous|continuously reading the XML log file]]. By receiving ''</group>'' you know that the command execution has finished.// |
===== [[elements]] Elements ===== | ===== [[elements]] Elements ===== | ||
Line 145: | Line 142: | ||
Example: | Example: | ||
- | &lt;code xml&gt; | + | <code xml> |
- | &lt;call&gt; | + | <call> |
- | &lt;command value=&quot;ps&quot; /&gt; | + | <command value="ps" /> |
- | &lt;destination value=&quot;/home/user&quot; /&gt; | + | <destination value="/home/user" /> |
- | &lt;output value=&quot; PID TTY TIME CMD | + | <output value=" PID TTY TIME CMD |
16969 ? 00:00:00 sshd | 16969 ? 00:00:00 sshd | ||
16970 ? 00:00:00 sftp-server | 16970 ? 00:00:00 sftp-server | ||
32647 ? 00:00:00 bash | 32647 ? 00:00:00 bash | ||
- | 1466 ? 00:00:00 ps&quot; /&gt; | + | 1466 ? 00:00:00 ps" /> |
- | &lt;result success=&quot;true&quot; /&gt; | + | <result success="true" /> |
- | &lt;/call&gt; | + | </call> |
- | &lt;/code&gt; | + | </code> |
Associated script commands: ''[[scriptcommand_call|call]]'' | Associated script commands: ''[[scriptcommand_call|call]]'' | ||
Line 170: | Line 167: | ||
Example: | Example: | ||
- | &lt;code xml&gt; | + | <code xml> |
- | &lt;checksum&gt; | + | <checksum> |
- | &lt;filename value=&quot;/home/martin/public_html/index.html&quot; /&gt; | + | <filename value="/home/martin/public_html/index.html" /> |
- | &lt;algorithm value=&quot;sha-1&quot; /&gt; | + | <algorithm value="sha-1" /> |
- | &lt;checksum value=&quot;bb4dfa9b51d3f6c99b5ec6c12ebf9cade79f43c4&quot; /&gt; | + | <checksum value="bb4dfa9b51d3f6c99b5ec6c12ebf9cade79f43c4" /> |
- | &lt;result success=&quot;true&quot; /&gt; | + | <result success="true" /> |
- | &lt;/checksum&gt; | + | </checksum> |
- | &lt;/code&gt; | + | </code> |
Associated script commands: ''[[scriptcommand_checksum|checksum]]'' | Associated script commands: ''[[scriptcommand_checksum|checksum]]'' | ||
Line 192: | Line 189: | ||
Example: | Example: | ||
- | &lt;code xml&gt; | + | <code xml> |
- | &lt;chmod recursive=&quot;true&quot;&gt; | + | <chmod recursive="true"> |
- | &lt;filename value=&quot;/home/martin/public_html/about.html&quot; /&gt; | + | <filename value="/home/martin/public_html/about.html" /> |
- | &lt;permissions value=&quot;rwxr-xr-x&quot; /&gt; | + | <permissions value="rwxr-xr-x" /> |
- | &lt;result success=&quot;true&quot; /&gt; | + | <result success="true" /> |
- | &lt;/chmod&gt; | + | </chmod> |
- | &lt;/code&gt; | + | </code> |
Associated script commands: ''[[scriptcommand_chmod|chmod]]'', ''[[scriptcommand_keepuptodate|keepuptodate]] -permissions'', ''[[scriptcommand_put|put]] -permissions'', ''[[scriptcommand_synchronize|synchronize]] remote|both -permissions'' | Associated script commands: ''[[scriptcommand_chmod|chmod]]'', ''[[scriptcommand_keepuptodate|keepuptodate]] -permissions'', ''[[scriptcommand_put|put]] -permissions'', ''[[scriptcommand_synchronize|synchronize]] remote|both -permissions'' | ||
Line 211: | Line 208: | ||
Example: | Example: | ||
- | &lt;code xml&gt; | + | <code xml> |
- | &lt;cp&gt; | + | <cp> |
- | &lt;filename value=&quot;/home/martin/public_html/about.html&quot; /&gt; | + | <filename value="/home/martin/public_html/about.html" /> |
- | &lt;destination value=&quot;/home/martin/backup/about.html.20171220&quot; /&gt; | + | <destination value="/home/martin/backup/about.html.20171220" /> |
- | &lt;result success=&quot;true&quot; /&gt; | + | <result success="true" /> |
- | &lt;/cp&gt; | + | </cp> |
- | &lt;/code&gt; | + | </code> |
Associated script commands: ''[[scriptcommand_cp|cp]]'' | Associated script commands: ''[[scriptcommand_cp|cp]]'' | ||
Line 231: | Line 228: | ||
Example: | Example: | ||
- | &lt;code xml&gt; | + | <code xml> |
- | &lt;download&gt; | + | <download> |
- | &lt;filename value=&quot;/home/martin/public_html/about.html&quot; /&gt; | + | <filename value="/home/martin/public_html/about.html" /> |
- | &lt;destination value=&quot;d:\www\about.htm&quot; /&gt; | + | <destination value="d:\www\about.htm" /> |
- | &lt;size value=&quot;55387&quot; /&gt; | + | <size value="55387" /> |
- | &lt;result success=&quot;true&quot; /&gt; | + | <result success="true" /> |
- | &lt;/download&gt; | + | </download> |
- | &lt;/code&gt; | + | </code> |
Associated script commands: ''[[scriptcommand_get|get]]'', ''[[scriptcommand_synchronize|synchronize]] local|both'' | Associated script commands: ''[[scriptcommand_get|get]]'', ''[[scriptcommand_synchronize|synchronize]] local|both'' | ||
Line 255: | Line 252: | ||
| ''type'' | Type of file as in Unix ''ls'' command output, e.g. ''d'' for directory (in ''value'' attribute) | | | ''type'' | Type of file as in Unix ''ls'' command output, e.g. ''d'' for directory (in ''value'' attribute) | | ||
| ''size'' | Size of file in bytes (in ''value'' attribute) | | | ''size'' | Size of file in bytes (in ''value'' attribute) | | ||
- | | ''modification'' | Modification timestamp (in ''value'' attribute)((All timestamps in the %%XML%% log have %%XML%% ''dateTime'' type, where only ''%%YYYY-MM-DD&quot;T&quot;HH:MM:SS.NNN&quot;Z&quot;%%'' syntax is used.)) | | + | | ''modification'' | Modification timestamp (in ''value'' attribute)((All timestamps in the %%XML%% log have %%XML%% ''dateTime'' type, where only ''%%YYYY-MM-DD"T"HH:MM:SS.NNN"Z"%%'' syntax is used.)) | |
| ''permissions'' | File permissions in Unix format ''rwxrwxrwx'' (in ''value'' attribute) | | | ''permissions'' | File permissions in Unix format ''rwxrwxrwx'' (in ''value'' attribute) | | ||
| ''owner'' | File owner (in ''value'' attribute) | | | ''owner'' | File owner (in ''value'' attribute) | | ||
Line 261: | Line 258: | ||
Example: | Example: | ||
- | &lt;code xml&gt; | + | <code xml> |
- | &lt;ls&gt; | + | <ls> |
- | &lt;destination value=&quot;/home/martin/public_html&quot; /&gt; | + | <destination value="/home/martin/public_html" /> |
- | &lt;files&gt; | + | <files> |
- | &lt;file&gt; | + | <file> |
- | &lt;filename value=&quot;.&quot; /&gt; | + | <filename value="." /> |
- | &lt;type value=&quot;d&quot; /&gt; | + | <type value="d" /> |
- | &lt;modification value=&quot;2008-12-22T12:16:23.000Z&quot; /&gt; | + | <modification value="2008-12-22T12:16:23.000Z" /> |
- | &lt;permissions value=&quot;rwxr-xr-x&quot; /&gt; | + | <permissions value="rwxr-xr-x" /> |
- | &lt;/file&gt; | + | </file> |
- | &lt;file&gt; | + | <file> |
- | &lt;filename value=&quot;..&quot; /&gt; | + | <filename value=".." /> |
- | &lt;type value=&quot;d&quot; /&gt; | + | <type value="d" /> |
- | &lt;modification value=&quot;2008-03-25T08:15:53.000Z&quot; /&gt; | + | <modification value="2008-03-25T08:15:53.000Z" /> |
- | &lt;permissions value=&quot;rwxr-xr-x&quot; /&gt; | + | <permissions value="rwxr-xr-x" /> |
- | &lt;/file&gt; | + | </file> |
- | &lt;file&gt; | + | <file> |
- | &lt;filename value=&quot;.htaccess&quot; /&gt; | + | <filename value=".htaccess" /> |
- | &lt;type value=&quot;-&quot; /&gt; | + | <type value="-" /> |
- | &lt;size value=&quot;107&quot; /&gt; | + | <size value="107" /> |
- | &lt;modification value=&quot;2008-12-02T06:59:58.000Z&quot; /&gt; | + | <modification value="2008-12-02T06:59:58.000Z" /> |
- | &lt;permissions value=&quot;rw-r--r--&quot; /&gt; | + | <permissions value="rw-r--r--" /> |
- | &lt;/file&gt; | + | </file> |
- | &lt;file&gt; | + | <file> |
- | &lt;filename value=&quot;about.html&quot; /&gt; | + | <filename value="about.html" /> |
- | &lt;type value=&quot;-&quot; /&gt; | + | <type value="-" /> |
- | &lt;size value=&quot;24064&quot; /&gt; | + | <size value="24064" /> |
- | &lt;modification value=&quot;2007-10-04T21:43:02.000Z&quot; /&gt; | + | <modification value="2007-10-04T21:43:02.000Z" /> |
- | &lt;permissions value=&quot;rw-r--r--&quot; /&gt; | + | <permissions value="rw-r--r--" /> |
- | &lt;/file&gt; | + | </file> |
- | &lt;/files&gt; | + | </files> |
- | &lt;result success=&quot;true&quot; /&gt; | + | <result success="true" /> |
- | &lt;/ls&gt; | + | </ls> |
- | &lt;/code&gt; | + | </code> |
Associated script commands: ''[[scriptcommand_ls|ls]]'' | Associated script commands: ''[[scriptcommand_ls|ls]]'' | ||
Line 306: | Line 303: | ||
Example: | Example: | ||
- | &lt;code xml&gt; | + | <code xml> |
- | &lt;mkdir&gt; | + | <mkdir> |
- | &lt;filename value=&quot;/home/martin/public_html/images&quot; /&gt; | + | <filename value="/home/martin/public_html/images" /> |
- | &lt;result success=&quot;true&quot; /&gt; | + | <result success="true" /> |
- | &lt;/mkdir&gt; | + | </mkdir> |
- | &lt;/code&gt; | + | </code> |
Associated script commands: ''[[scriptcommand_keepuptodate|keepuptodate]]'', ''[[scriptcommand_mkdir|mkdir]]'', ''[[scriptcommand_put|put]]'', ''[[scriptcommand_synchronize|synchronize]] remote|both'' | Associated script commands: ''[[scriptcommand_keepuptodate|keepuptodate]]'', ''[[scriptcommand_mkdir|mkdir]]'', ''[[scriptcommand_put|put]]'', ''[[scriptcommand_synchronize|synchronize]] remote|both'' | ||
Line 324: | Line 321: | ||
Example: | Example: | ||
- | &lt;code xml&gt; | + | <code xml> |
- | &lt;mv&gt; | + | <mv> |
- | &lt;filename value=&quot;/home/martin/public_html/about.html&quot; /&gt; | + | <filename value="/home/martin/public_html/about.html" /> |
- | &lt;destination value=&quot;/tmp/about.bak&quot; /&gt; | + | <destination value="/tmp/about.bak" /> |
- | &lt;result success=&quot;true&quot; /&gt; | + | <result success="true" /> |
- | &lt;/mv&gt; | + | </mv> |
- | &lt;/code&gt; | + | </code> |
Associated script commands: ''[[scriptcommand_mv|mv]]'' | Associated script commands: ''[[scriptcommand_mv|mv]]'' | ||
Line 344: | Line 341: | ||
Example: | Example: | ||
- | &lt;code xml&gt; | + | <code xml> |
- | &lt;rm recursive=&quot;true&quot;&gt; | + | <rm recursive="true"> |
- | &lt;filename value=&quot;/home/martin/public_html/images&quot; /&gt; | + | <filename value="/home/martin/public_html/images" /> |
- | &lt;result success=&quot;true&quot; /&gt; | + | <result success="true" /> |
- | &lt;/rm&gt; | + | </rm> |
- | &lt;/code&gt; | + | </code> |
Associated script commands: ''[[scriptcommand_get|get]] -delete'', ''[[scriptcommand_keepuptodate|keepuptodate]] -delete'', ''[[scriptcommand_rm|rm]]'', ''[[scriptcommand_rmdir|rmdir]]'', ''[[scriptcommand_synchronize|synchronize]] local|both -delete'' | Associated script commands: ''[[scriptcommand_get|get]] -delete'', ''[[scriptcommand_keepuptodate|keepuptodate]] -delete'', ''[[scriptcommand_rm|rm]]'', ''[[scriptcommand_rmdir|rmdir]]'', ''[[scriptcommand_synchronize|synchronize]] local|both -delete'' | ||
Line 362: | Line 359: | ||
Example: | Example: | ||
- | &lt;code xml&gt; | + | <code xml> |
- | &lt;stat&gt; | + | <stat> |
- | &lt;filename value=&quot;/home/martin/public_html/about.html&quot; /&gt; | + | <filename value="/home/martin/public_html/about.html" /> |
- | &lt;file&gt; | + | <file> |
- | &lt;type value=&quot;-&quot; /&gt; | + | <type value="-" /> |
- | &lt;size value=&quot;24064&quot; /&gt; | + | <size value="24064" /> |
- | &lt;modification value=&quot;2007-10-04T21:43:02.000Z&quot; /&gt; | + | <modification value="2007-10-04T21:43:02.000Z" /> |
- | &lt;permissions value=&quot;rw-r--r--&quot; /&gt; | + | <permissions value="rw-r--r--" /> |
- | &lt;/file&gt; | + | </file> |
- | &lt;result success=&quot;true&quot; /&gt; | + | <result success="true" /> |
- | &lt;/stat&gt; | + | </stat> |
- | &lt;/code&gt; | + | </code> |
Associated script commands: ''[[scriptcommand_stat|stat]]'' | Associated script commands: ''[[scriptcommand_stat|stat]]'' | ||
Line 387: | Line 384: | ||
Example: | Example: | ||
- | &lt;code xml&gt; | + | <code xml> |
- | &lt;upload&gt; | + | <upload> |
- | &lt;filename value=&quot;d:\www\about.htm&quot; /&gt; | + | <filename value="d:\www\about.htm" /> |
- | &lt;destination value=&quot;/home/martin/public_html/about.html&quot; /&gt; | + | <destination value="/home/martin/public_html/about.html" /> |
- | &lt;size value=&quot;55387&quot; /&gt; | + | <size value="55387" /> |
- | &lt;result success=&quot;true&quot; /&gt; | + | <result success="true" /> |
- | &lt;/upload&gt; | + | </upload> |
- | &lt;/code&gt; | + | </code> |
Associated script commands: ''[[scriptcommand_keepuptodate|keepuptodate]]'', ''[[scriptcommand_put|put]]'', ''[[scriptcommand_synchronize|synchronize]] remote|both'' | Associated script commands: ''[[scriptcommand_keepuptodate|keepuptodate]]'', ''[[scriptcommand_put|put]]'', ''[[scriptcommand_synchronize|synchronize]] remote|both'' | ||
Line 404: | Line 401: | ||
^ Element ^ Description ^ | ^ Element ^ Description ^ | ||
| ''filename'' | Absolute path to remote file (in ''value'' attribute) | | | ''filename'' | Absolute path to remote file (in ''value'' attribute) | | ||
- | | ''modification'' | Modification timestamp (in ''value'' attribute)((All timestamps in the %%XML%% log have %%XML%% ''dateTime'' type, where only ''%%YYYY-MM-DD&quot;T&quot;HH:MM:SS.NNN&quot;Z&quot;%%'' syntax is used.)) | | + | | ''modification'' | Modification timestamp (in ''value'' attribute)((All timestamps in the %%XML%% log have %%XML%% ''dateTime'' type, where only ''%%YYYY-MM-DD"T"HH:MM:SS.NNN"Z"%%'' syntax is used.)) | |
Example: | Example: | ||
- | &lt;code xml&gt; | + | <code xml> |
- | &lt;touch&gt; | + | <touch> |
- | &lt;filename value=&quot;/home/martin/public_html/about.html&quot; /&gt; | + | <filename value="/home/martin/public_html/about.html" /> |
- | &lt;modification value=&quot;2008-12-28T11:22:19.000Z&quot; /&gt; | + | <modification value="2008-12-28T11:22:19.000Z" /> |
- | &lt;result success=&quot;true&quot; /&gt; | + | <result success="true" /> |
- | &lt;/touch&gt; | + | </touch> |
- | &lt;/code&gt; | + | </code> |
Associated script commands: ''[[scriptcommand_keepuptodate|keepuptodate]]'', ''[[scriptcommand_put|put]] -preservetime'', ''[[scriptcommand_synchronize|synchronize]] remote|both'' | Associated script commands: ''[[scriptcommand_keepuptodate|keepuptodate]]'', ''[[scriptcommand_put|put]] -preservetime'', ''[[scriptcommand_synchronize|synchronize]] remote|both'' | ||
Line 424: | Line 421: | ||
//Note that the ''[[#group|group]]'' elements will be included, if enabled only.// | //Note that the ''[[#group|group]]'' elements will be included, if enabled only.// | ||
- | &lt;code xml&gt; | + | <code xml> |
- | &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; | + | <?xml version="1.0" encoding="UTF-8"?> |
- | &lt;session xmlns=&quot;http://winscp.net/schema/session/1.0&quot; | + | <session xmlns="http://winscp.net/schema/session/1.0" |
- | name=&quot;martin@example.com&quot; start=&quot;2012-01-04T14:25:53.173Z&quot;&gt; | + | name="martin@example.com" start="2012-01-04T14:25:53.173Z"> |
- | &lt;group name=&quot;put -preservetime -permissions=644 d:\www\about.htm&quot; start=&quot;2012-01-04T14:28:45.393Z&quot;&gt; | + | <group name="put -preservetime -permissions=644 d:\www\about.htm" start="2012-01-04T14:28:45.393Z"> |
- | &lt;upload&gt; | + | <upload> |
- | &lt;filename value=&quot;d:\www\about.htm&quot; /&gt; | + | <filename value="d:\www\about.htm" /> |
- | &lt;destination value=&quot;/home/martin/public_html/about.html&quot; /&gt; | + | <destination value="/home/martin/public_html/about.html" /> |
- | &lt;result success=&quot;true&quot; /&gt; | + | <result success="true" /> |
- | &lt;/upload&gt; | + | </upload> |
- | &lt;touch&gt; | + | <touch> |
- | &lt;filename value=&quot;/home/martin/public_html/about.html&quot; /&gt; | + | <filename value="/home/martin/public_html/about.html" /> |
- | &lt;modification value=&quot;2008-12-28T11:22:19.000Z&quot; /&gt; | + | <modification value="2008-12-28T11:22:19.000Z" /> |
- | &lt;result success=&quot;true&quot; /&gt; | + | <result success="true" /> |
- | &lt;/touch&gt; | + | </touch> |
- | &lt;chmod&gt; | + | <chmod> |
- | &lt;filename value=&quot;/home/martin/public_html/about.html&quot; /&gt; | + | <filename value="/home/martin/public_html/about.html" /> |
- | &lt;permissions value=&quot;rw-r--r--&quot; /&gt; | + | <permissions value="rw-r--r--" /> |
- | &lt;result success=&quot;true&quot; /&gt; | + | <result success="true" /> |
- | &lt;/chmod&gt; | + | </chmod> |
- | &lt;/group&gt; | + | </group> |
- | &lt;group name=&quot;rm about.bak&quot; start=&quot;2012-01-04T14:28:47.892Z&quot;&gt; | + | <group name="rm about.bak" start="2012-01-04T14:28:47.892Z"> |
- | &lt;rm&gt; | + | <rm> |
- | &lt;filename value=&quot;/home/martin/public_html/about.bak&quot; /&gt; | + | <filename value="/home/martin/public_html/about.bak" /> |
- | &lt;result success=&quot;false&quot;&gt; | + | <result success="false"> |
- | &lt;message&gt;No such file or directory. | + | <message>No such file or directory. |
Error code: 2 | Error code: 2 | ||
Error message from server: No such file | Error message from server: No such file | ||
- | Request code: 13&lt;/message&gt; | + | Request code: 13</message> |
- | &lt;/result&gt; | + | </result> |
- | &lt;/rm&gt; | + | </rm> |
- | &lt;failure&gt; | + | <failure> |
- | &lt;message&gt;No such file or directory. | + | <message>No such file or directory. |
Error code: 2 | Error code: 2 | ||
Error message from server: No such file | Error message from server: No such file | ||
- | Request code: 13&lt;/message&gt; | + | Request code: 13</message> |
- | &lt;/failure&gt; | + | </failure> |
- | &lt;/group&gt; | + | </group> |
- | &lt;/session&gt; | + | </session> |
- | &lt;/code&gt; | + | </code> |
===== [[parse]] Interpreting/Parsing ===== | ===== [[parse]] Interpreting/Parsing ===== | ||
Line 482: | Line 479: | ||
For example to generate a plain text list of successfully downloaded files from the following %%XML%% log (''log.xml''): | For example to generate a plain text list of successfully downloaded files from the following %%XML%% log (''log.xml''): | ||
- | &lt;code xml&gt; | + | <code xml> |
- | &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; | + | <?xml version="1.0" encoding="UTF-8"?> |
- | &lt;session xmlns=&quot;http://winscp.net/schema/session/1.0&quot; name=&quot;user@host&quot; start=&quot;2021-12-03T06:45:57.008Z&quot;&gt; | + | <session xmlns="http://winscp.net/schema/session/1.0" name="user@host" start="2021-12-03T06:45:57.008Z"> |
- | &lt;download&gt; | + | <download> |
- | &lt;filename value=&quot;/path/file1.txt&quot; /&gt; | + | <filename value="/path/file1.txt" /> |
- | &lt;destination value=&quot;C:\path\file1.txt&quot; /&gt; | + | <destination value="C:\path\file1.txt" /> |
- | &lt;size value=&quot;2022&quot; /&gt; | + | <size value="2022" /> |
- | &lt;result success=&quot;true&quot; /&gt; | + | <result success="true" /> |
- | &lt;/download&gt; | + | </download> |
- | &lt;download&gt; | + | <download> |
- | &lt;filename value=&quot;/path/file2.txt&quot; /&gt; | + | <filename value="/path/file2.txt" /> |
- | &lt;destination value=&quot;C:\path\file2.txt&quot; /&gt; | + | <destination value="C:\path\file2.txt" /> |
- | &lt;size value=&quot;5782&quot; /&gt; | + | <size value="5782" /> |
- | &lt;result success=&quot;true&quot; /&gt; | + | <result success="true" /> |
- | &lt;/download&gt; | + | </download> |
- | &lt;/session&gt; | + | </session> |
- | &lt;/code&gt; | + | </code> |
use the following %%XSLT%% (''download.xslt''): | use the following %%XSLT%% (''download.xslt''): | ||
- | &lt;code xml&gt; | + | <code xml> |
- | &lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt; | + | <?xml version="1.0" encoding="UTF-8"?> |
- | &lt;xsl:stylesheet version=&quot;1.0&quot; xmlns:xsl=&quot;http://www.w3.org/1999/XSL/Transform&quot; xmlns:winscp=&quot;http://winscp.net/schema/session/1.0&quot;&gt; | + | <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:winscp="http://winscp.net/schema/session/1.0"> |
- | &lt;xsl:output method=&quot;text&quot; encoding=&quot;UTF-8&quot;/&gt; | + | <xsl:output method="text" encoding="UTF-8"/> |
- | &lt;xsl:strip-space elements=&quot;*&quot;/&gt; | + | <xsl:strip-space elements="*"/> |
- | &lt;xsl:template match='winscp:download[winscp:result[@success=&quot;true&quot;]]/winscp:filename'&gt; | + | <xsl:template match='winscp:download[winscp:result[@success="true"]]/winscp:filename'> |
- | &lt;xsl:value-of select=&quot;@value&quot;/&gt; | + | <xsl:value-of select="@value"/> |
- | &lt;xsl:text&gt;&amp;#xa;&lt;/xsl:text&gt; | + | <xsl:text>
</xsl:text> |
- | &lt;/xsl:template&gt; | + | </xsl:template> |
- | &lt;/xsl:stylesheet&gt; | + | </xsl:stylesheet> |
- | &lt;/code&gt; | + | </code> |
You can execute it using any %%XSLT%% processor: | You can execute it using any %%XSLT%% processor: | ||
- | * Microsoft ''msxsl.exe'' (deprecated, but [[https://web.archive.org/web/20200202112313/https://www.microsoft.com/en-us/download/details.aspx?displaylang=en&amp;id=21714|available from Internet Archive]]): \\ &lt;code&gt; | + | * .NET [[dotnet>system.xml.xsl.xslcompiledtransform|''XslCompiledTransform'' class]], e.g. from PowerShell: \\ <code powershell> |
- | msxsl.exe log.xml download.xslt | + | $xslt = New-Object System.Xml.Xsl.XslCompiledTransform |
- | &lt;/code&gt; | + | $xslt.Load("download.xslt") |
- | * [[http://xmlsoft.org/|Libxml2]] ''xsltproc.exe'': \\ &lt;code&gt; | + | $xslt.Transform("log.xml", "download.txt")</code> |
+ | * [[https://gitlab.gnome.org/GNOME/libxml2/-/wikis/home|Libxml2]] ''xsltproc.exe'': \\ <code> | ||
xsltproc.exe download.xslt log.xml | xsltproc.exe download.xslt log.xml | ||
- | &lt;/code&gt; | + | </code> |
The output will be: | The output will be: | ||
- | &lt;code&gt; | + | <code> |
/path/file1.txt | /path/file1.txt | ||
/path/file2.txt | /path/file2.txt | ||
- | &lt;/code&gt; | + | </code> |
For a more complex example, see [[script_custom_listing_format_csv#scripting|*]]. | For a more complex example, see [[script_custom_listing_format_csv#scripting|*]]. | ||
- | |||
- | 1 |