Carriage Return lost during SFTP

Advertisement

BTSim
Joined:
Posts:
1
Location:
SG

Carriage Return lost during SFTP

Hi,


Source - Windows 2016
Target - Windows 2018 R2 Standard

Client - WinSCP - 5.13.3

Script commands -
start /wait xxxx/WinSCP.exe /log="%logpath%%logfile%" /command "option batch on" "option confirm off" "open sftp://%uname%@%hostip%:%portnum% -hostkey=""%hostkeynum%"" -rawsettings KEX=dh-group1-sha1 -privatekey=%privatekeyloc%" "option transfer ascii" "cd %remotedir%" "lcd %localdir%" "put -delete -nopreservetime %filetype%" "exit"

Issue :
Files generated in the source server has "Carriage Return" but after FTP the "Carriage Return" was lost and left with "LineFeed"

Resolution -
change the mode of transfer from ascii to binary

Found similar article but the server OS and the client WinScP version is not the same though.

Appreciate your advice
Many tks

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
32,114
Location:
Prague, Czechia

Re: Carriage Return lost during SFTP

I do not understand your question.
You know that the solution is to use the binary mode. So why are you using the ascii mode?

Reply with quote

Guest

Re: Carriage Return lost during SFTP

martin wrote:

I do not understand your question.
You know that the solution is to use the binary mode. So why are you using the ascii mode?

Hi ,

Yes , the solution is to change to "binary" but is this loss of the "carriage return" WinSCP client issue or the server end settings as in what is the root cause of it ?

I am using the same WINSCP version and scripting to connect to transfer to another server but I did not get missing "Carriage Return" which is also Windows 2008 R2

The scenarios
Source server --> Target A server --> missing "carriage return" using winSCP5.3.13
Source server (same as above) --> Target B server --> NO missing "carriage return" using winSCP5.3.13

regards

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
32,114
Location:
Prague, Czechia

Re: Carriage Return lost during SFTP

Most SFTP servers do not support the ascii mode at all.
When connected to such server, WinSCP simulates the ascii mode by converting the file on its own.
By default, WinSCP assumes a *nix server, so it converts CR+LF => LF.
This is obviously wrong, if you are connecting to a Windows server.
When connected to Windows server, either avoid using the ascii mode, or tell WinSCP that the server is Windows (which will effectively prevent WinSCP from using the ascii mode, even if told to).
https://winscp.net/eng/docs/ui_login_environment

Reply with quote

Advertisement

You can post new topics in this forum