Re: Scripting example to change transfer mode from BINARY to ASCII
They are using WinSCP SFTP and since the default is BINARY mode, it is dropping the CR from the CR/LF in the file on way to our Windows server.
Binary mode does not drop anything. Binary mode transfers the file as is, without any change.
So if there's no CR in a file uploaded using binary mode, it was not in the original file in the first place.
Anyway to answer your question:
Can you provide an example of the command to switch the mode from BINARY to ASCII? I found on your site the switch-transfer
is available, but I am not sure where they should place it in their code and also what more there is to it. Is it-transfer
ASCII or what?
put -transfer=ascii "C:\local\path\file.ext" "/remote/path/file.ext"
See https://winscp.net/eng/docs/scriptcommand_put
Though as majority of SFTP servers actually do not support ascii mode, it is simulated by WinSCP. For that, WinSCP needs to know, what EOL sequence does the server use. If you want to add CR, modify your
open
command as:
open sftp://.../ -rawsettings EOLType=1
See:
https://winscp.net/eng/docs/scriptcommand_open
https://winscp.net/eng/docs/rawsettings#eoltype
WinSCP can generate a script template with all these options for you:
https://winscp.net/eng/docs/ui_generateurl#script