Just found the solution, I didn't realize that ftplib has 'passive mode' as the standard - so I ended up with never actually trying to use 'active mode'....
Thanks nonetheless :) Am Dienstag, den 19.08.2008, 15:16 +0200 schrieb Paul Schewietzek: > Hello everyone, > > > > I put together the following, most of it is from different howtos on the > web. > > <code> > #!/usr/bin/env python > # -*- coding: utf-8 -*- > > def gettext(ftp, filename, outfile=None): > if outfile is None: > outfile = sys.stdout > ftp.retrlines("RETR %s" % filename, lambda s, w=outfile.write: > w(s+"\n")) > > def main(): > from ftplib import FTP > import datetime > ftp = FTP("ftp.ftpserver.com") > ftp.login("my_username", "my_passwd") > ftp.set_pasv(1) > > filename = "name_of_textfile" > outfile = open(filename, "w") > > ftp.cwd("OUT") > gettext(ftp, filename, outfile) > ftp.quit() > > if __name__ == "__main__": > main() > </code> > > The script actually runs fine when "ftp.ftpserver.com" == "my_server_a", > however when "ftp.ftpserver.com" == "my_server_b", it produces: > > <snip> > Traceback (most recent call last): > File "/usr/local/bin/get_afendis_STATS_from_ftp.py", line 24, in ? > main() > File "/usr/local/bin/get_afendis_STATS_from_ftp.py", line 20, in main > gettext(ftp, filename, outfile) > File "/usr/local/bin/get_afendis_STATS_from_ftp.py", line 7, in > gettext > ftp.retrlines("RETR %s" % filename, lambda s, w=outfile.write: w(s > +"\n")) > File "/usr/lib/python2.4/ftplib.py", line 396, in retrlines > conn = self.transfercmd(cmd) > File "/usr/lib/python2.4/ftplib.py", line 345, in transfercmd > return self.ntransfercmd(cmd, rest)[0] > File "/usr/lib/python2.4/ftplib.py", line 324, in ntransfercmd > conn.connect(sa) > File "<string>", line 1, in connect > socket.error: (110, 'Connection timed out') > </snip> > > So it looks like "my_server_b" has some different requirements or > something? I don't have much experience with the ftp-protocol, so I > thought maybe you guys could point me in the right direction? > > The files are definitely existent on the servers, and when I connect to > them via the shell, I can up- and download files as I want. > > Seems like the call to ftp.retrlines() somehow doesn't work... > > I'm also not sure about ftp.set_pasv(1). > > > > Regards, Paul > > _______________________________________________ > Tutor maillist - Tutor@python.org > http://mail.python.org/mailman/listinfo/tutor _______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor