This project is read-only.

sFTP in binary or ASCII

Apr 18, 2012 at 6:16 PM

I transferred a  text file from a Windows PC to Linux Server. If you open them up in vim the end each line has a ^M.

I don't see a file transfer encoding  binary/ASCII option. I didn't find any examples to solve this.

I can bring the text files from Linux Server to PC without an issue.

Did I miss something in the library for this?

I tried scpClient  Upload and the sftpClient UploadFile, and got the same results.

Thanks.

Apr 24, 2012 at 3:24 PM

After further testing .. It seems at this time my problem is that the VSFTP on the Linux server was not allowing ascii mode. I changed the setting in the configuration file and it transfers from my XP box just fine. I won't get a chance to test with this library until next week sometime.

Apr 24, 2012 at 3:28 PM

thanks for an update,

 

I am sorry I didnt reply early, currently busy with other project I have to finish.

 

When you have a chance to investigate more, please let me know what you find if there is anything I can chnange in my library to make it work in both cases correctly.

 

Thanks,

Oleg

May 2, 2012 at 4:40 PM

I am posting my findings in case someone else has an issue with this.

I am used to the normal FTP - where you have the options for binary/ascii mode. (ASCII mode removes the \r  for text file transferring from Windows to Linux)

The SFTP - has no such option as ASCII mode.

(When you do a help for commands available, there is no listing for ascii/binary) 

SFTP in putty doesn't have this option.

I could find nothing in the RFC 4254 (SSH) about binary / ascii. The only mention of ASCII is for sending the commands to the server in ASCII mode.

The best answer I found was the man page for ssh: ...is used to reliably transfer binary data ...

This library does works just fine transferring files in binary as per the ssh man page.

 

 

May 3, 2012 at 12:02 PM

 

you could try running dos2unix on the ascii file after it transfers... that should fix the carrige returns in the file. (I have this problem myself on 1 system I work with)

 

alternatively, you could compress the file beore you send, scp it across and uncompress it on the linux host... that way you will actually be sending a binary file... not an ascii one.

That might work but since linux and windows handle carrige returns a little differently, I am not convinced.

 

cheers,

Paul