Topic "CR/LF being replaced with LF during scripted transfer"

Author Message
[View user's profile]

Joined: 2009-05-06
Posts: 2
Using v4.1.8 on Windows Server 2003
I'm using WinSCP in a SQL Server 2005 Integration Services package (Execute Process task) as follows

Executable: C:\Program Files\WinSCP\WinSCP.exe
Arguments: -script=\\dcf\data$\shared_sh\mirror.txt

Contents of mirror.txt (redacted)

option batch on
option confirm off
open sftp://username:password@server.IP.address:22
option transfer ascii
put \\dcf\data$\Shared_SH\mgnfin_leg_dignity_6_0409.csv
put \\dcf\data$\Shared_SH\mgnfin_leg_dignity_6_0409.sum

The two files being transferred are plain text with CR/LF line delimiters (I've doublechecked this with a hex editor!). The files transfer fine but I've had a message back from the recipient that CR/LF has been replaced with LF in the file. I have no idea what software is running at the other end. I can't see an option in the help for setting the line delimiter in a script. If it's relevant, I have to use UNC names as mapped drives are not available to the domain account which runs the process.

Any tips?

[View user's profile]

Joined: 2007-10-25
Posts: 51
Use binary transfer mode instead of ascii and the translation should stop.

The manual setting of mode should also circumvent any automatic text mode, but you might have to remove the rule for that file type if it does not.
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 24759
Location: Prague, Czechia
Exactly. Use "option transfer binary".
See documentation to understand transfer modes.
Martin Prikryl
[View user's profile]

Joined: 2009-05-06
Posts: 2
Thank you both. My initial reasoning was that if I'm sending a text file, the transfer mode should be ASCII but reading the suggested page in the manual explained why that was wrong, so I've learned something which is more generally useful.



Hi ,

I have a .txt file on windows which is being ftp'd to windows folder. File looks aligned (line by line ) on the server.
But the same file data looks jumbled once ftp'd. Can some one please tell me how to get over this?

Ex of files that I am seeing on server and windows

On server :


On windows :


Each line is a record and we would like to see it (in windows) the way it is on server. I tried using binary option but it is still the same.



I got the solution for the above posted issue. I used ASCII m ode instead of BINARY. Now on windows file data looks aligned.


You can post new topics in this forum

Search Site

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!


About donations

$9   $19   $49   $99

About donations


WinSCP Privacy Policy

WinSCP License