LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 09-14-2009, 03:17 PM   #1
clvic
Member
 
Registered: Feb 2008
Location: Rome, Italy
Distribution: OpenSuSE 11.x, vectorlinux, slax, Sabayon
Posts: 206
Blog Entries: 2

Rep: Reputation: 45
Problem with FTP ascii transfer


Hi everyone,
I had a problem with the old good ascii/binary FTP transfer modes.
I transferred some files (SQL scripting files, in which carriage returns DO matter) using FTP from a windows system to a linux system using filezilla "auto" mode, that should have resulted in ASCII mode for my sql files. These files are well formed and identical to the originals.
Then, someone else picked these files and moved them to another ftp server.
I finally found that all <CR><LF> couples have been transformed in <CR><CR><LF>.

I guessed that the problem was in the ASCII transfer mode - but, how comes that <CR><LF> => <CR><CR><LF>? I would have rather expected <CR><LF> to become <CR>.

I hope I've been clear, thanks to everyone that will answer!
 
Old 09-14-2009, 04:01 PM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
That sounds odd. A slight tangent, but an alternative is to simply transfer the files in binary mode only -- and then use dos2unix / unix2dos to do the conversion for you.
 
Old 09-14-2009, 07:11 PM   #3
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835

Rep: Reputation: 102Reputation: 102
Quote:
Originally Posted by clvic View Post
Hi everyone,
I had a problem with the old good ascii/binary FTP transfer modes.
I transferred some files (SQL scripting files, in which carriage returns DO matter) using FTP from a windows system to a linux system using filezilla "auto" mode, that should have resulted in ASCII mode for my sql files. These files are well formed and identical to the originals.
Then, someone else picked these files and moved them to another ftp server.
I finally found that all <CR><LF> couples have been transformed in <CR><CR><LF>.

I guessed that the problem was in the ASCII transfer mode - but, how comes that <CR><LF> => <CR><CR><LF>? I would have rather expected <CR><LF> to become <CR>.

I hope I've been clear, thanks to everyone that will answer!
It is easier to solve a problem like this than to try to diagnose it. Write a script that finds line endings (of any kind) and converts them to your preferred line ending. Regardless of the script language, the essential regex looks like this:

/(\r|\n)+/\n/

BUT ... before using this method, make sure there are no intentionally blank lines (e.g. multiple line endings with no intervening text) such as one finds in plain-text documents. For that case, you really do need to specify the exact line ending you are looking for:

/\r\r\n/\n/

Again, this is an example where a cure is much easier than a diagnosis.

Quote:
I would have rather expected <CR><LF> to become <CR>.
Only on a Macintosh:

Macintosh: \r
Windows: \r\n
Linux/most Unices: \n
 
  


Reply

Tags
ascii, binary, ftp



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
gzip: stdin: invalid compressed data--format violated ftp ascii transfer sridhar_dct3 Linux - Software 10 07-28-2012 02:25 PM
how to force pure-ftp to not use ascii neocontrol Linux - Server 2 07-26-2007 07:34 AM
HTTP and FTP transfer problem boimmnrg Linux - Server 0 03-26-2007 10:37 PM
FTP ascii mode messed up my files! :-( Ictus Linux - General 9 03-31-2006 03:19 PM
Linux/UNIX differences with vi and ftp ascii transfers KenMadsen Linux - Newbie 2 06-20-2005 09:51 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 02:39 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration