0

Ok, so ... I have a python program that needs to upload a file to a FTP , but somehow I keep getting a

TimeoutError: [Errno 60] Operation timed out 

I'm a beginner so most likely I'm doing something wrong,but after some trail and errors I'm still stuck. Also, when I have to introduce a regex to search for a file which constantly changes its name, python interprets the regex as a string and not as code. Why does that happen? Please excuse my ignorance...

import ftplib
import bz2

filename = "cv(\d+)"
ftp = ftplib.FTP("host", port, timeout)
ftplib.FTP.connect("host","user","pass", port, timeout)

ftp.write(bz2.compress("pass"))

ftp.prot_p()          # switch to secure data connection

ftp.storeline('STOR'+filename)
ftp.quit()
Mazdak
  • 105,000
  • 18
  • 159
  • 188
Beta_K
  • 69
  • 1
  • 2
  • 10
  • Please check [this similar post](http://stackoverflow.com/questions/3451817/python-ftplib-timing-out), maybe it can help. – Wiktor Stribiżew Sep 04 '15 at 09:41
  • 1
    I don't think the FTP protocol understands Perl-like regex. If anything, it might understand glob syntax, but take this as a grain of salt, since I'm not sure about it. – nhahtdh Sep 04 '15 at 10:28

0 Answers0