python - List files with pyftp - proftpd vs. pyftpdlib behavior -
i have test code uses ftp stub pyftpdlib, surprise failed in production. reason proftpd returns directory name in response nlst. here response pyftpdlib ftp stub:
in [10]: local_conn.login('user', '12345') out[10]: '230 login successful.' in [11]: import ftplib in [12]: local_conn = ftplib.ftp() in [13]: local_conn.connect('localhost', 2121) out[13]: '220 pyftpdlib 1.4.0 ready.' in [14]: local_conn.login('user', '12345') out[14]: '230 login successful.' in [15]: local_conn.nlst('structuredata_advanced') out[15]: ['report_20150618.csv', 'report_20150618.fin', 'report_20150619.csv', 'report_20150619.fin', 'report_20150620.csv', 'report_20150620.fin'] here response proftpd:
in [16]: remote_conn = ftplib.ftp() in [17]: remote_conn.connect('a1b.7y.xx.xx', 21) out[17]: '220 proftpd 1.3.4a server (vztd3.company.com) [a1b.7y.xx.xx]' in [18]: remote_conn.login('remoteuser', 'verysecret') out[18]: '230 user yougov logged in' in [19]: remote_conn.nlst('structuredata_advanced') out[19]: ['structuredata_advanced/report_20150624.csv', 'structuredata_advanced/report_20150629.csv', 'structuredata_advanced/report_20150625.fin', 'structuredata_advanced/report_20150628.fin', 'structuredata_advanced/report_20150627.fin', 'structuredata_advanced/report_20150620.fin', 'structuredata_advanced/report_20150619.csv', ...] it's easy enough remove directory names:
# code works both in production , testing files = conn.nlst(basedir) # proftd weired returns basedir name files = [f.split('/')[-1] f in files] but understand if pyftpdlib wrong?
can configured in proftpd?
there need know ftp protocol , nlst command?
update
i tested ftp server called uftpd behaves pyftpdlib when issuing nlst.
i'm author of uftpd.
i googled bit, turns out djb wrote aboute this while back, , unfortunately seems output differs between servers.
my interpretation though is; recommended not prefix each output file in given directory directory name. i.e., if client sends 'nlst dir' server should not reply:
dir/a dir/b but instead output files in directory dir/ this:
a b
Comments
Post a Comment