Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error_perm: 500 Unknown command Python ftplib storbinary

Tags:

python

ftplib

I'm trying to upload a file using ftplib in Python.

ftp = FTP('...')
ftp.login('user', 'pass')                   
f = open(filename)
ftp.storbinary(filename, f)
f.close()
ftp.quit()

storbinary is returning error_perm: 500 Unknown command., which is strange since I'm following its specification. Google search returns very little information. Anyone encountered this problem ?

like image 306
FranGoitia Avatar asked Oct 14 '15 17:10

FranGoitia


1 Answers

It looks like you're using storbinary incorrectly. You want to pass "STOR filename-at-location", f) to send the file. Does this work?

ftp = FTP('...')
ftp.login('user', 'pass')
with open(filename) as contents:
    ftp.storbinary('STOR %s' % filename, contents)
ftp.quit()
like image 94
Tom Avatar answered Nov 10 '22 00:11

Tom