Status Code 3 appearing on files that are not transferring?

Advertisement

bkarabinchak.psi
Joined:
Posts:
2

Status Code 3 appearing on files that are not transferring?

I have a java server technology (Ignition by Inductive Automation specifically) that calls a batch file that is meant to use WinSCP to transfer some text files overnight to our customer. It is not working and I am not sure why.

Here is the batch file – actual information has been changed so any typos are not representative of actual batch file. I actually do this for two files, by finding a second file using a similar loop assigning it to a different variable and calling the same WinSCP script after with the the same
"C:\Program Files (x86)\WinSCP\WinSCP.exe" SiteName /log=c:\temp\winscp2.log /loglevel=* /privatekey=C:\Keys\key_nopassphrase.ppk /command "open sftp://User:password.url.net:6055/" "cd firstdirectory\secondDirectory\"  "put %filePathData%" "close"
command but a file path/bash variable.
set sftpPathData=C:\SFTP\Up\Data*.txt.gpg
echo sftpPathData
FOR /F "delims=|" %%I IN ('DIR %sftpPathData% /B /O:D') DO SET NewestDataFile=%%I
echo NewestDataFile is %NewestDataFile%
set filePathData=C:\SFTP\Up\%NewestDataFile%
"C:\Program Files (x86)\WinSCP\WinSCP.exe" SiteName /log=c:\temp\winscp2.log /loglevel=* /privatekey=C:\Keys\key_nopassphrase.ppk /command "open sftp://User:password.url.net:6055/" "cd firstdirectory\secondDirectory\"  "put %filePathData%" "close"
exit /b
I call this via a python (technically jython) subprocess call and log the stderr, but I don't see any issues there – nothing in my logs the past month come through for the stderr.

In the WinSCP logs this is what I see – I am truncating a lot but showing what I believe is relevant, it logs in and attempts to copy the file over but I see a Status Code 3 whereas previously when it was working this was a Status Code 0.

Logs from this morning -
. 2022-01-07 04:10:02.120 Copying "C:\SFTP\Up\Data01072020.txt.gpg" to remote directory started.
. 2022-01-07 04:10:02.120 Binary transfer mode selected.
. 2022-01-07 04:10:02.120 Opening remote file.
> 2022-01-07 04:10:02.120 Type: SSH_FXP_OPEN, Size: 76, Number: 771
< 2022-01-07 04:10:02.520 Type: SSH_FXP_HANDLE, Size: 10, Number: 771
> 2022-01-07 04:10:02.521 Type: SSH_FXP_WRITE, Size: 4118, Number: 1286
. 2022-01-07 04:10:02.523 16 skipped SSH_FXP_WRITE, SSH_FXP_READ, SSH_FXP_DATA and SSH_FXP_STATUS packets.
> 2022-01-07 04:10:02.523 Type: SSH_FXP_CLOSE, Size: 10, Number: 5636
> 2022-01-07 04:10:02.523 Type: SSH_FXP_SETSTAT, Size: 72, Number: 1033
< 2022-01-07 04:10:02.547 Type: SSH_FXP_STATUS, Size: 49, Number: 1286
< 2022-01-07 04:10:02.561 Type: SSH_FXP_STATUS, Size: 49, Number: 1542
< 2022-01-07 04:10:02.561 Type: SSH_FXP_STATUS, Size: 49, Number: 1798
< 2022-01-07 04:10:02.564 Type: SSH_FXP_STATUS, Size: 49, Number: 2054
< 2022-01-07 04:10:02.565 Type: SSH_FXP_STATUS, Size: 49, Number: 2310
< 2022-01-07 04:10:02.579 Type: SSH_FXP_STATUS, Size: 49, Number: 2566
< 2022-01-07 04:10:02.583 Type: SSH_FXP_STATUS, Size: 49, Number: 2822
< 2022-01-07 04:10:02.586 Type: SSH_FXP_STATUS, Size: 49, Number: 3078
< 2022-01-07 04:10:02.587 Type: SSH_FXP_STATUS, Size: 49, Number: 3334
< 2022-01-07 04:10:02.588 Type: SSH_FXP_STATUS, Size: 49, Number: 3590
< 2022-01-07 04:10:02.588 Type: SSH_FXP_STATUS, Size: 49, Number: 3846
< 2022-01-07 04:10:02.588 Type: SSH_FXP_STATUS, Size: 49, Number: 4102
< 2022-01-07 04:10:02.595 Type: SSH_FXP_STATUS, Size: 49, Number: 4358
< 2022-01-07 04:10:02.601 Type: SSH_FXP_STATUS, Size: 49, Number: 4614
< 2022-01-07 04:10:02.601 Type: SSH_FXP_STATUS, Size: 49, Number: 4870
< 2022-01-07 04:10:02.602 Type: SSH_FXP_STATUS, Size: 49, Number: 5126
< 2022-01-07 04:10:02.602 Type: SSH_FXP_STATUS, Size: 49, Number: 5382
< 2022-01-07 04:10:02.772 Type: SSH_FXP_STATUS, Size: 40, Number: 5636
< 2022-01-07 04:10:02.772 Status code: 0
. 2022-01-07 04:10:02.772 Preserving timestamp [2022-01-07T09:00:01.000Z]
< 2022-01-07 04:10:02.807 Type: SSH_FXP_STATUS, Size: 176, Number: 1033
< 2022-01-07 04:10:02.807 Status code: 3
. 2022-01-07 04:10:02.807 Transfer done: 'C:\SFTP\Up\Data01072020.txt.gpg' [65702]
> 2022-01-07 04:10:02.808 Script: close
. 2022-01-07 04:10:02.808 Closing connection.
. 2022-01-07 04:10:02.808 Sending special code: 12
. 2022-01-07 04:10:02.808 Sent EOF message

When this was working this line -
< 2022-01-07 04:10:02.807 Status code: 3
would appear as this instead -
< 2021-10-077 04:10:03.752 Status code: 0
But I can't seem to find any information regarding what the difference is or how I could resolve it. Any help is greatly appreciated.

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,441
Location:
Prague, Czechia

Re: Status Code 3 appearing on files that are not transferring?

To me it looks like this issue:
Why is uploaded file not showing in a remote directory or showing with a different name?

The code 3 is most likely a failed attempt to update timestamp of the just uploaded file that was meanwhile deleted/moved. Why it sometimes succeeds and sometimes fails can be just timing issue. Sometimes WinSCP might manage to update the timestamp before the file gets deleted/moved, sometimes not. You may want to disable timestamp update with -nopreservetime switch of the put command:
https://winscp.net/eng/docs/scriptcommand_put#nopreservetime

Your duplicate post on Stack Overflow:
Status Code 3 at the end of WinSCP SFTP upload

Reply with quote

bkarabinchak.psi

Doing put -nopreservetime did make the Status Code: 3 go away and now I only see Status Code: 0's which is good. Am waiting for the other side to confirm to me that this is now working properly and that they received the expected files but it certainly looks that way now from my end. Thank you Martin!

Reply with quote

Advertisement

You can post new topics in this forum