I'm trying to upload a file in Python to a FileZilla FTP server at ftp.scratso.com, however I keep getting this error:
Traceback (most recent call last):
File "PythianRealms.py", line 2332, in <module>
ftp = ftplib.FTP("ftp.scratso.com", "PythianRealms", "password")
File "C:\Python32\lib\ftplib.py", line 115, in __init__
self.login(user, passwd, acct)
File "C:\Python32\lib\ftplib.py", line 400, in login
resp = self.sendcmd('USER ' + user)
File "C:\Python32\lib\ftplib.py", line 255, in sendcmd
return self.getresp()
File "C:\Python32\lib\ftplib.py", line 230, in getresp
raise error_proto(resp)
ftplib.error_proto: written by Tim Kosse (Tim.Kosse@gmx.de)
I've tried searching for solutions to this, but I haven't found this issue occur elsewhere.
The code is this (password changed):
ftp = ftplib.FTP("ftp.scratso.com", "PythianRealms", "password")
mapsock = urllib.request.urlopen("http://92.234.196.233/launcher-version.txt")
mapnum = str(mapsock.read()).split("'")[1]
mapsock.close()
f = open("tempmap.txt", "rb")
ftp.storbinary("STOR "+mapnum+".prm", f)
f.close()
ftp.quit()
Any help would be appreciated.
Thank you.
Edit: In the server log, it shows:
(000185)13/09/2015 11:47:38 - (not logged in) (92.234.196.233)> 220 FileZilla Server version 0.9.41 beta written by Tim Kosse (Tim.Kosse@gmx.de) Please visit http://sourceforg
(000185)13/09/2015 11:47:38 - (not logged in) (92.234.196.233)> USER PythianRealms
(000185)13/09/2015 11:47:38 - (not logged in) (92.234.196.233)> 331 Password required for pythianrealms
The server sends back the following welcome message:
220 FileZilla Server version 0.9.41 beta\r
written by Tim Kosse (Tim.Kosse@gmx.de)\r
Please visit http://sourceforg\r\n
This is a very strange welcome message, since it is kind of multi-line but not proper multi-line. The lines are delimited by \r only instead of \r\n and it does not follow the standard used for a FTP multi-line response, i.e. that the first line should be "220-...." and the last line "220 ...".
While I can not see a clear definition of the characters allowed inside a single line of the response in RFC 959 text is commonly defined to not include control characters like \r apart from the line end. Thus it is no wonder that ftplib cannot properly deal with this strange response.