Hi We are having some problems - the majority of our files require ascii transfers between our unix servers and PCs. They are however being transferred as binary for some reason even though they are just plain text files. This means (when going from unix to pc) the files come down without a carriage return at the end of lines. And when going from pc to unix they end up with ^M on the end of each line. Anyone have any ideas? TIA Sue Sue Gray sjgray@subcorp.com.au Network Analyst A.S.C.
On Wed, 25 Nov 1998, Gray, Sue wrote:> We are having some problems - the majority of our files require ascii > transfers between our unix servers and PCs. They are however being > transferred as binary for some reason even though they are just plain > text files.The reason is simple: There is no way for a computer to tell a text file from a binary file. It can make a guess, based on content or filename, but it cannot tell for sure. If it guesses wrong and does end-of-line translation on a binary file (an executable, for example), the results would be catastrophic. Also, the SMB protocol has no way (that I know of) to tell the server what end-of-line sequence it wants. A UNIX SMB client, a Windows SMB client, and a Mac SMB client all want different things. Which one should the server do? This is why FTP has a "binary" mode and an "ascii" mode.> Anyone have any ideas?There are utilities for almost any platform to convert text files between the three popular end-of-line styles (CR, LF, and CR+LF). Some text editors auto-detect the end-of-line sequence in use and adjust accordingly. They can do this because a text editor is always editing text. It is theoretically possible to write code that would have Samba scan file names, look for a ".TXT" extension, and do end-of-line translation for you. However, this would cause a large performance hit, and unreliable for the reasons I described above. This is really the job of the client, anyway. Ask Microsoft to add it to the Windows SMB client. :-) ---------------------------------------------------------------------- Benjamin Scott <bscott@hamptonsys.com> Phone: (603)431-7315 Hampton Systems Group, Inc. Fax : (603)431-0822 http://www.hamptonsys.com DSN : 852-3581 ======================================================================
>We are having some problems - the majority of our files require ascii >transfers between our unix servers and PCs. They are however being >transferred as binary for some reason even though they are just plain >text files. This means (when going from unix to pc) the files come down >without a carriage return at the end of lines. And when going from pc to >unix they end up with ^M on the end of each line. Anyone have any >ideas?All transfers via Samba are 'binary' - the ascii text conversion is a feature of FTP, but it is not automatic. Samba cannot tell the difference between text and binary files, and transfers everything as binary. CU! Mike. --- Mike Pelley mike@pelley.com
> We are having some problems - the majority of our files require ascii > transfers between our unix servers and PCs. They are however being > transferred as binary for some reason even though they are just plain > text files. This means (when going from unix to pc) the files come down > without a carriage return at the end of lines. And when going from pc to > unix they end up with ^M on the end of each line. Anyone have any > ideas?Here are 2 shell scripts that come with IRIX. to_dos works fine on both IRIX and AIX. I haven't tried to_unix yet. to_dos: #! /bin/sh -e # convert a UNIX ASCII file to a DOS ASCII file by appending ^M at the # end of each line and ^Z at the end of the file TMPFILE=/tmp/to_dos$$ if [ $# -gt 2 ] then echo "usage: to_dos [<unix_file> [<dos_file>]]" exit 1 fi if [ $# -gt 0 ] then nawk '{printf("%s\r\n", $0);}' "$1" > $TMPFILE else nawk '{printf("%s\r\n", $0);}' > $TMPFILE fi # Stick on the EOF character echo '^Z\c' >> $TMPFILE if [ $# -eq 2 ] then mv -f $TMPFILE "$2" else cat $TMPFILE rm $TMPFILE fi to_unix: #! /bin/sh -e # convert a DOS ASCII file to a UNIX ASCII file by removing trailing ^M at the # end of each line and ^Z at the end of the file TMPFILE=/tmp/to_unix$$ if [ $# -gt 2 ] then echo "usage: to_unix [<dos_file> [<unix_file>]]" exit 1 fi # First strip out all carriage-return and ctrl-Z's if [ $# -gt 0 ] then tr -d '\015\032' < "$1" > $TMPFILE else tr -d '\015\032' > $TMPFILE fi if [ $# -eq 2 ] then mv -f $TMPFILE "$2" else cat $TMPFILE rm $TMPFILE fi Regards, Dave Lawson CAD Coordinator Menasco Aerospace Oakville, Ontario (905) - 827-7777 ext. 398