3

I am having problems transferring a text file from Windows 7 using ftp.exe to a FreeBSD server. After the file transfer the end-of-line characters are not changed from \r\n to \n, Instead they remain with the carriage return character which can be seen in for example mcedit as ^M. The file is transferred in ascii mode.

Has anybody run into similar problems in the past? As far as I know using the ascii mode during FTP transfer should convert those characters automatically. Does it depend on the server configuration?

EDIT: The file can be seen here.

EDIT: I have also tried with ncftp.exe under Cygwin but the result is the same. The carriage return character has not been removed even if the transfer type was ASCII.

EDIT: It does not work the other way round either. I created a text file in FreeBSD and then downloaded it is ASCII mode to my Windows machine. The end of line characters remained LF as they were in FreeBSD.

EDIT: The lit stat returns

211-FTP server status:
 Connected to 160.135.126.21
 Logged in as user
 TYPE: ASCII
 No session bandwidth limit
 Session timeout in seconds is 320
 Control connection is plain text
 Data connections will be plain text
 At session startup, client count was 9
 vsFTPd 2.3.4 - secure, fast, stable
211 End of status
Jagger
  • 133
  • 6
  • Is this UTF or ASCII? Is it like XML? Or is it source code? Check the header of the file in hex dump that it's a normal file. – Andrew Smith Jul 01 '12 at 16:42
  • @AndrewSmith: No, it is a "normal" txt file created by `notepad.exe`. It is not an XML file. I also put a link to the file. – Jagger Jul 01 '12 at 16:45
  • So this is FTP Server, because windows client does this conversion by default on *.txt files. – Andrew Smith Jul 01 '12 at 16:50
  • Well windows client can do this, are you sure you have this problem, e.g. you are in ASCII mode? Do you have windows XP? – Andrew Smith Jul 01 '12 at 16:54
  • @AndrewSmith: Yes I am sure, that I am in `ASCII` mode. Right now I am trying with another `ftp` client I will update my question with the results of this research. As described in the question I use `Windows 7`. – Jagger Jul 01 '12 at 17:21
  • What FTP server software are you running? If it's the built-in software (which I highly doubt, as I run that and it works beautifully), otherwise what software/port are you running? What version of FreeBSD? The client software does not do the conversion, only the server software does. So you can try any client you want, it will never matter. – Chris S Jul 01 '12 at 22:15
  • @ChrisS: The problem is that I do not own the server. I can check only the version `FreeBSD 8.2-RELEASE-p9 FreeBSD 8.2-RELEASE-p9`. Do you know if there is any configuration file of the ftp server I can look at? – Jagger Jul 02 '12 at 01:59
  • If you can run `pkg_info` check that for a FTP Server. The build-in FTP server is configured via `/etc/inetd.conf`, the default file has the FTP server on the first line of the servers list. The built-in server is somewhat limited in capacity, though quite feature complete; so it's common to replace it with a higher performance server in high utilization and multi-tenant situations. – Chris S Jul 02 '12 at 02:18
  • @ChrisS: It looks like the only built-in `ftpd` is installed and running. Does it not do the conversion by default? – Jagger Jul 02 '12 at 02:58
  • The built-in server has conversion, that can't be disabled (to my knowledge); so I'm thinking you've got another server installed/running. FTP to the server and enter `lit stat`, it should return "Version 6.00LS" with some other connection related information. – Chris S Jul 02 '12 at 03:15
  • @ChrisS I put the `lit stat` output at the end of the question. It returns `vsFTPd 2.3.4`. – Jagger Jul 02 '12 at 03:28

1 Answers1

4

vsFTPd, in a misguided effort to make their daemon "very secure", has disabled ASCII EoL conversion by default. It has to be manually re-enabled by editing the configuration (/usr/local/etc/vsftpd.conf by default) file and adding the following lines:

ascii_upload_enable=YES
ascii_download_enable=YES
Chris S
  • 77,337
  • 11
  • 120
  • 212
  • Thank you! This solved the problem. Right now the conversion is done automatically when in `ASCII` mode. – Jagger Jul 02 '12 at 18:16
  • Those settings seems completely backwards. When set to NO, unix(mac)-to-unix FTP converted files to crlf line endings. Enabling the setting results in files with the correct unix-lf newline line endings. Thanks! – joemaller Jan 15 '15 at 16:11