cygwin rsync and ascii files

matthew.2.burgess at bt.com matthew.2.burgess at bt.com
Fri Jun 28 04:22:35 EST 2002


> I am ysyncing text files between NT/95/XP machines and Solaris.   I noted
> that the text/ascii files created on the windows platforms contain ^M at
> the end of each line when transfered to the Solaris system.  This can be
> explained by the binary transmission and can use FTP is ASCII mode to
> prevent this from happening.  It is crutial that we preserve the time
> stamp, so running dos2unix isn't one of the top solutions (unless I write
> something to touch the file back to the "original" time).  Is there an
> option to rsync files in ASCII mode?  I would also appreciate and
entertain
> other solutions.

Could you not just use a shell script on the Solaris Side once you've
rsynced
the files across? This may be over simplified but it's the first thing that
popped in my head):

---- Begin Psuedo-code ----

For textFile in listOfFiles
  originalTime=`ls -l $textFile | cut time/date field`
  sed $textFile replacing ^M with proper unix line endings
  touch -amt $originalTime $textFile
Loop

---- End Psuedo-code ----

Hope this helps,

Matt Burgess



-----Original Message-----
From: David Starks-Browning [mailto:starksb at ebi.ac.uk]
Sent: Friday, June 28, 2002 11:43
To: michael.protulipac at pncbank.com
Cc: rsync at lists.samba.org
Subject: cygwin rsync and ascii files


On Thursday 27 Jun 02, michael.protulipac at pncbank.com writes:
> I am ysyncing text files between NT/95/XP machines and Solaris.   I noted
> that the text/ascii files created on the windows platforms contain ^M at
> the end of each line when transfered to the Solaris system.  This can be
> explained by the binary transmission and can use FTP is ASCII mode to
> prevent this from happening.  It is crutial that we preserve the time
> stamp, so running dos2unix isn't one of the top solutions (unless I write
> something to touch the file back to the "original" time).  Is there an
> option to rsync files in ASCII mode?  I would also appreciate and
entertain
> other solutions.

I can't think of any way to do this with rsync as shipped.  If you
need to *use* those text files on both Windows and UNIX, is there a
way for you to create them with UNIX line endings in the first place?
The only Windows application I know of that cannot handle UNIX
line-endings is Notepad.

You could try modifying rsync to open text files in text mode on
Windows.  I haven't tried it, but it might strip the ^M for you.  Just
be careful you don't open binary files this way, or they could get
corrupted.  (This approach is probably be too simplistic.)  In any
case, I think your only hope is to modify your copy of rsync to suit
you, possibly in combination with a dos2unix filter on the Windows
side.

There are other techniques to force text v. binary file methods in
Cygwin, using /usr/lib/textmode.o for example.  Figure all that out
using Cygwin docs and resources at <http://cygwin.com/>, not here.

Good luck, I can imagine this feature would be useful to others, so
please keep us informed.

Thanks,
David
(Cygwin FAQ maintainer)


-- 
To unsubscribe or change options:
http://lists.samba.org/mailman/listinfo/rsync
Before posting, read: http://www.tuxedo.org/~esr/faqs/smart-questions.html




More information about the rsync mailing list