I am trying to implement FTP download from a UNIX server into a windows box. I have got this far(code below) , but get an error specifying a file object is required but str
is passed
Code
#!/usr/bin/python
import ftplib
filename = "filename"
ftp = ftplib.FTP("xx.xxx.xxx.xxx")
ftp.login("uid", "psw")
ftp.cwd("/my/location")
print filename
ftp.retrbinary('RETR %s' % filename, file.write)
Error
Traceback (most recent call last):
File "FTP.py", line 10, in <module>
ftp.retrbinary('RETR %s' % filename, file.write)
File "/usr/lib/python2.6/ftplib.py", line 399, in retrbinary
callback(data)
TypeError: descriptor 'write' requires a 'file' object but received a 'str'
Can anyone advise how to sort this. Also if possible where can I get some sample examples to learn Python FTP.