2

我正在使用 WinSCP 通过 SFTP 自动上传文件。我在1级开启了debug log,能查到文件是否上传成功吗?谢谢你。

部分日志文件:

. 2012-08-30 15:30:06.539 File: "C:\files\file_20120830.gpg"
. 2012-08-30 15:30:06.539 Copying "C:\files\file_20120830.gpg" to remote directory started.
. 2012-08-30 15:30:06.539 Binary transfer mode selected.
. 2012-08-30 15:30:06.539 Checking existence of file.
> 2012-08-30 15:30:06.539 Type: SSH_FXP_LSTAT, Size: 50, Number: 263
. 2012-08-30 15:30:06.539 Sent 54 bytes
. 2012-08-30 15:30:06.539 There are 0 bytes remaining in the send buffer
. 2012-08-30 15:30:06.539 Waiting for another 4 bytes
. 2012-08-30 15:30:06.555 Detected network event
. 2012-08-30 15:30:06.555 Received 33 bytes (0)
. 2012-08-30 15:30:06.555 Read 4 bytes (29 pending)
. 2012-08-30 15:30:06.555 Read 29 bytes (0 pending)
< 2012-08-30 15:30:06.555 Type: SSH_FXP_STATUS, Size: 29, Number: 263
< 2012-08-30 15:30:06.555 Status code: 2
. 2012-08-30 15:30:06.555 Checking existence of partially transfered file.
> 2012-08-30 15:30:06.555 Type: SSH_FXP_LSTAT, Size: 59, Number: 519
. 2012-08-30 15:30:06.555 Sent 63 bytes
. 2012-08-30 15:30:06.555 There are 0 bytes remaining in the send buffer
. 2012-08-30 15:30:06.555 Waiting for another 4 bytes
. 2012-08-30 15:30:06.570 Detected network event
. 2012-08-30 15:30:06.570 Received 33 bytes (0)
. 2012-08-30 15:30:06.570 Read 4 bytes (29 pending)
. 2012-08-30 15:30:06.570 Read 29 bytes (0 pending)
< 2012-08-30 15:30:06.570 Type: SSH_FXP_STATUS, Size: 29, Number: 519
< 2012-08-30 15:30:06.570 Status code: 2
. 2012-08-30 15:30:06.570 Opening remote file.
> 2012-08-30 15:30:06.570 Type: SSH_FXP_OPEN, Size: 75, Number: 771
. 2012-08-30 15:30:06.570 Sent 79 bytes
. 2012-08-30 15:30:06.570 There are 0 bytes remaining in the send buffer
. 2012-08-30 15:30:06.570 Waiting for another 4 bytes
. 2012-08-30 15:30:06.586 Detected network event
. 2012-08-30 15:30:06.586 Received 31 bytes (0)
. 2012-08-30 15:30:06.586 Read 4 bytes (27 pending)
. 2012-08-30 15:30:06.586 Read 27 bytes (0 pending)
< 2012-08-30 15:30:06.586 Type: SSH_FXP_HANDLE, Size: 27, Number: 771
. 2012-08-30 15:30:06.586 Write request offset: 0, len: 4096
> 2012-08-30 15:30:06.586 Type: SSH_FXP_WRITE, Size: 4135, Number: 1286
. 2012-08-30 15:30:06.586 Sent 4139 bytes
. 2012-08-30 15:30:06.586 There are 0 bytes remaining in the send buffer
. 2012-08-30 15:30:06.586 Write request offset: 4096, len: 4096
> 2012-08-30 15:30:06.586 Type: SSH_FXP_WRITE, Size: 4135, Number: 1542
. 2012-08-30 15:30:06.586 Sent 4139 bytes
. 2012-08-30 15:30:06.586 There are 0 bytes remaining in the send buffer
. 2012-08-30 15:30:06.586 Write request offset: 8192, len: 4096
> 2012-08-30 15:30:06.586 Type: SSH_FXP_WRITE, Size: 4135, Number: 1798
. 2012-08-30 15:30:06.586 Sent 4139 bytes
. 2012-08-30 15:30:06.586 There are 0 bytes remaining in the send buffer
. 2012-08-30 15:30:06.586 Write request offset: 12288, len: 4096
> 2012-08-30 15:30:06.586 Type: SSH_FXP_WRITE, Size: 4135, Number: 2054
. 2012-08-30 15:30:06.586 Sent 4139 bytes
. 2012-08-30 15:30:06.586 There are 0 bytes remaining in the send buffer
. 2012-08-30 15:30:06.586 Write request offset: 16384, len: 4096
> 2012-08-30 15:30:06.586 Type: SSH_FXP_WRITE, Size: 4135, Number: 2310
. 2012-08-30 15:30:06.586 Sent 4139 bytes
. 2012-08-30 15:30:06.586 There are 0 bytes remaining in the send buffer
. 2012-08-30 15:30:06.586 Write request offset: 20480, len: 4096
> 2012-08-30 15:30:06.586 Type: SSH_FXP_WRITE, Size: 4135, Number: 2566
. 2012-08-30 15:30:06.586 Sent 4139 bytes
. 2012-08-30 15:30:06.586 There are 0 bytes remaining in the send buffer
. 2012-08-30 15:30:06.586 Write request offset: 24576, len: 4096
> 2012-08-30 15:30:06.586 Type: SSH_FXP_WRITE, Size: 4135, Number: 2822
. 2012-08-30 15:30:06.602 Sent 4139 bytes
. 2012-08-30 15:30:06.602 There are 0 bytes remaining in the send buffer
. 2012-08-30 15:30:06.602 Write request offset: 28672, len: 98261
> 2012-08-30 15:30:06.602 Type: SSH_FXP_WRITE, Size: 98300, Number: 3078
. 2012-08-30 15:30:06.617 Sent 98304 bytes
. 2012-08-30 15:30:06.617 There are 33208 bytes remaining in the send buffer
. 2012-08-30 15:30:06.617 Detected network event
. 2012-08-30 15:30:06.617 Received 28 bytes (0)
. 2012-08-30 15:30:06.617 Read 4 bytes (24 pending)
. 2012-08-30 15:30:06.617 Read 24 bytes (0 pending)
< 2012-08-30 15:30:06.617 Type: SSH_FXP_STATUS, Size: 24, Number: 1286
< 2012-08-30 15:30:06.617 Status code: 0
. 2012-08-30 15:30:06.617 There are 33208 bytes remaining in the send buffer, need to send at least another 440 bytes
. 2012-08-30 15:30:06.633 Detected network event
. 2012-08-30 15:30:06.633 There are 33208 bytes remaining in the send buffer
. 2012-08-30 15:30:06.633 There are 33208 bytes remaining in the send buffer, need to send at least another 440 bytes
. 2012-08-30 15:30:06.633 Detected network event
. 2012-08-30 15:30:06.633 There are 33208 bytes remaining in the send buffer
. 2012-08-30 15:30:06.633 There are 33208 bytes remaining in the send buffer, need to send at least another 440 bytes
. 2012-08-30 15:30:06.633 Detected network event
. 2012-08-30 15:30:06.633 Received 28 bytes (0)
. 2012-08-30 15:30:06.633 Read 4 bytes (24 pending)
. 2012-08-30 15:30:06.633 Read 24 bytes (0 pending)
< 2012-08-30 15:30:06.633 Type: SSH_FXP_STATUS, Size: 24, Number: 1542
< 2012-08-30 15:30:06.633 Status code: 0
4

3 回答 3

3

引用 WinSCP 常见问题我如何知道脚本已成功完成?

您可以通过 WinSCP 退出代码来判断脚本的结果。代码 0 表示成功,而 1 表示错误。有关更多详细信息,请参阅脚本文档。

一旦发生任何错误,批处理脚本(使用/script/command 命令行开关指定)立即以代码 1 终止。option batch您可以使用命令更改此设置。

要找出脚本失败的原因,请检查会话日志

有关示例,请参见:

如果您需要更好地控制错误处理,请考虑改用WinSCP .NET 程序集(例如,来自PowerShell 脚本)。

于 2014-06-17T14:22:39.093 回答
1

WinSCP 可以选择将所有操作记录到XML 日志中。然后,您可以分析日志以准确了解会话期间发生的情况。

于 2013-03-20T09:13:09.907 回答
1

下面,是我用来完成从 ftp 服务器同步到本地目录的批处理文件,删除本地端的任何更改。批处理文件还保存所有传输的XML 日志

@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"" / 

您要使用的参数是“ winscp.exe /log="C:\Sync\logs!M-!D-!Y@!T.xml" /xmlgroups "

于 2013-09-05T05:02:30.843 回答