vmedhe2
vmedhe2

Reputation: 237

FTP via Python cant get it move files

Hey I wanted to learn to FTP via python and found some code, I have been testing it but cant seem to get it to work.

import ftplib
from ftplib import FTP 

File2Send = "D:\Backup\ZipFilesToMove\send.txt"
Output_Directory = "\\vm-backupus\FTP\Databases\Sort"
ftp = FTP("xxx.xxx.xxx.xxx") #I have the IP but I didnt want to give it out
ftp.login('ShowME.ftp', 'pword01') 
file = open(File2Send, "rb") 
ftp.cwd(Output_Directory)
ftp.storbinary('STOR ' + os.path.basename(File2Send), open(file)) 
print "STORing File now..." 
ftp.quit() 
file.close() 

I keep getting this error, any ideas why and how to solve it.

Traceback (most recent call last):
File "C:\BackupFiles\Test.py", line 9, in <module>
ftp.cwd(Output_Directory)
File "C:\Python27\lib\ftplib.py", line 562, in cwd
return self.voidcmd(cmd)
File "C:\Python27\lib\ftplib.py", line 254, in voidcmd
return self.voidresp()
File "C:\Python27\lib\ftplib.py", line 229, in voidresp
resp = self.getresp()
File "C:\Python27\lib\ftplib.py", line 224, in getresp
raise error_perm, resp
error_perm: 550 The system cannot find the path specified. 

Upvotes: 2

Views: 3445

Answers (2)

Swoogan
Swoogan

Reputation: 5558

Your path is wrong:

File "C:\BackupFiles\Test.py", line 9, in <module>
ftp.cwd(Output_Directory)

error_perm: 550 The system cannot find the path specified. 

Furthermore, it looks suspicious:

Output_Directory = "\\vm-backupus\FTP\Databases\Sort"

Your double backslash indicates Windows network share syntax, not an FTP path. The path you are trying to change directory into should be relative or absolute from the FTP root. It looks like you are trying to change to where the directory lives outside of the FTP server, instead of inside it.

You should log into the server with the username and password using an FTP client and verify what the absolute path is. It won't start with "\" and it won't use backslashes. Something like '/Databases/Sort'

Also, make sure that you have the name right. For example 'vm-backupus' is more likely 'vm-backups'.

Upvotes: 0

Burhan Khalid
Burhan Khalid

Reputation: 174624

The error 550 The system cannot find the path specified. tells you that the path to your server is invalid.

In other words, this: \\vm-backupus\FTP\Databases\Sort is not a valid location on the FTP server.

Upvotes: 1

Related Questions