-2

I was trying this FTP file transfer code. The thing is that when I had run this code on an online environment(a workspace that I created on Cloud 9) then it worked fine and uploaded the file but when I run this on my PC I get an ERROR. How can I resolve it?

from ftplib import FTP

ftp=FTP('**domain**')
ftp.login(user='username',passwd='password')
ftp.cwd('/')

def grabFile():
    filename='fileName.txt'
    localfile=open(filename, 'wb')
    ftp.retrbinary('RETR '+filename, localfile.write, 1024)
    ftp.quit()
    localfile.close()

def placeFile():
    filename= 'Strinzy.txt'
    ftp.storbinary('STOR '+filename, open(filename,'rb'))
    ftp.quit()

placeFile()

ERROR:

Traceback (most recent call last):
  File "ftp_trial.py", line 19, in <module>
    placeFile()
  File "ftp_trial.py", line 16, in placeFile
    ftp.storbinary('STOR '+filename, open(filename,'rb'))
  File "/usr/lib/python2.7/ftplib.py", line 468, in storbinary
    conn = self.transfercmd(cmd, rest)
  File "/usr/lib/python2.7/ftplib.py", line 373, in transfercmd
    return self.ntransfercmd(cmd, rest)[0]
  File "/usr/lib/python2.7/ftplib.py", line 332, in ntransfercmd
    conn = socket.create_connection((host, port), self.timeout)
  File "/usr/lib/python2.7/socket.py", line 571, in create_connection
    raise err
socket.error: [Errno 113] No route to host
Strinzy
  • 41
  • 2
  • 7
  • "No route to host" - isn't that obvious? Does it work if you use a different FTP client? – Ulrich Eckhardt Mar 29 '16 at 06:27
  • @Strinzy What happens if you actually try fixing the problem? :) ...and by "try fixing", I mean searching for your errors on google and SO, reading documentation, experimenting by writing a bit of test code, etc. You could start the experiment by pinging one machine from the other. – jDo Mar 29 '16 at 06:45

1 Answers1

-1

If you are using vsftpd then make sure your vsftpd service is running in your machine and /etc/vsftpd.userlist has username in it.

Vishal Yarabandi
  • 427
  • 1
  • 4
  • 9