LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux > 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

Tags used in this thread
Popular LQ Tags , ,

Reply
 
Thread Tools
Old 09-14-2009, 04:17 PM   #1
clvic
Member
 
Registered: Feb 2008
Location: Rome, Italy
Distribution: OpenSuSE 10.x, vectorlinux, slax
Posts: 171
Blog Entries: 1
Thanked: 14
Problem with FTP ascii transfer


[Log in to get rid of this advertisement]
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!
linuxsuse clvic is offline  
Tag This Post , ,
Reply With Quote
Old 09-14-2009, 05:01 PM   #2
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Fedora, FreeBSD
Posts: 2,386
Thanked: 81
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.
linuxfedora anomie is offline     Reply With Quote
Thanked by:
Old 09-14-2009, 08:11 PM   #3
lutusp
Member
 
Registered: Sep 2009
Distribution: Fedora
Posts: 835
Thanked: 136
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
linuxfedora lutusp is offline     Reply With Quote
Thanked by:

Reply

Bookmarks


Thread Tools

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 6 08-08-2008 03:15 AM
how to force pure-ftp to not use ascii neocontrol Linux - Server 2 07-26-2007 08:34 AM
HTTP and FTP transfer problem boimmnrg Linux - Server 0 03-26-2007 11:37 PM
FTP ascii mode messed up my files! :-( Ictus Linux - General 9 03-31-2006 04:19 PM
Linux/UNIX differences with vi and ftp ascii transfers KenMadsen Linux - Newbie 2 06-20-2005 10:51 AM


All times are GMT -5. The time now is 01:20 PM.

Main Menu
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
RSS2  LQ Podcast
RSS2  LQ Radio
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration