Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

martin

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
Pennie

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