Scripting example to change transfer mode from BINARY to ASCII

Advertisement

Pennie
Joined:
Posts:
1
Location:
USA

Scripting example to change transfer mode from BINARY to ASCII

We have a customer pushing files from their Linux server to our Windows server. 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. 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? Thanks so much. Pennie

Reply with quote

Advertisement

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

Re: Scripting example to change transfer mode from BINARY to ASCII

Pennie wrote:

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

Reply with quote

Advertisement

You can post new topics in this forum