Long shot question,...
 

Subscribe now and choose from over 30 free gifts worth up to £49 - Plus get £25 to spend in our shop

[Closed] Long shot question, Python, ftplib and the OPTS command

2 Posts
3 Users
0 Reactions
113 Views
Posts: 7
Free Member
Topic starter
 

Thought I would see if anyone knows about this. I'm writing a python script to download all files from a server that is in my office. The library, ftplib looked like the way to go. However it fails at login. A quick try with the windows 10 FTP app also failed. Wireshark showed that when an FTP connection is opened, the client sends the OPTS command. The server is an old design with a subset of FTP commands and it doesn't have the OPTS command. This is what caused the problem as it reports an error.

Apparently the windows FTP app didn't used to send the OPTS command, but the new windows 10 version does. I strongly suspect that ftplib is a wrapper to the underlying OS FTP app.

Is there any way of preventing the OP\ts command from being sent?


 
Posted : 28/09/2019 5:52 pm
Posts: 2050
Full Member
 

Technet Article

This article describes the same issue that you are having. The suggested workaround is to use the ftp.exe file from Windows 7 on your Windows 10 system.

HTH

If you find a better fix please share it.


 
Posted : 28/09/2019 7:05 pm
Posts: 7090
Full Member
 

Looking at the source code for ftplib, it seems to only send the OPTS command when you do an mlsd with the facts array set to non-None.

https://github.com/python/cpython/blob/3.5/Lib/ftplib.py#L591

So perhaps you could just avoid that particular path?

Or maybe you could monkey-patch it to filter out the OPTS command?


 
Posted : 28/09/2019 7:38 pm