You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Implement 'rules' or 'wildcards' in GetListing #1246
Hi! Thanks for answering so soon.
About rules I supposed that was the problem.
However, as long as I know, wildcards do work in server side. Couldn't it be nice Getlisting implement that?
RFC 959 (purposely?) does not go into any detail at all about the inferred meaning of filepath, pathname etc. when it describes the function of the LIST, RETR etc. etc. commands that take such a parameter.
Thus, in the past, different FTP (RFC 959) server implementations have taken various liberties in implementing wildcards, and to which degree.
The wildcard functionality that you can achieve today, currently depends entirely on the server that you are connecting to.
Here is an example, using an up-to-date ProFTPD server.
...
Command: PWD
Response: 257 "/home/mike" is the current directory [<1ms]
> GetListing("*.bin", Auto)
Command: PASV
Status: Waiting for response to: PASV
Response: 227 Entering Passive Mode (192,168,1,109,154,73). [1ms]
Status: Connecting to IP #1= ***:39497
Command: MLSD /home/mike/*.bin
Response: 550 /home/mike/*.bin: No such file or directory [<1ms]
...
As you can see, on this server type, MLSD with wildcards is rejected.
...
Command: LIST /home/mike/*.bin
Response: 150 Opening BINARY mode data connection for file list [<1ms]
+---------------------------------------+
Listing: -rw-r--r-- 1 mike mike 6 Sep 18 2022 /home/mike/test.bin
-----------------------------------------
and the list items are populated correctly.
Therefore, I don't totally understand what you are asking for. Wildcards work, when the server supports them. You just need to find the right way to code it, and do some experiments to see what works and what does not.
If your wish is to support wildcards client-side, i.e. for servers that do not support them, then okay, that is a possibly valid enhancement request, although you can easily handle that in your own code.
Once more this is a good example why adding some example code and log output to show what you are trying to do, would have been a good idea, to save some time in speculation.
However, as long as I know, wildcards do work in server side. Couldn't it be nice Getlisting implement that?
It doesn't need to. The server does it. You just need to read up on GetListing and find out how to ask it to do the right thing.
As first parameter in GetListing is path, I didn't think it was possible to add a wildcard.
So, I've been doing the filtering in client side.
My aim is to populate a treview node with the pdfs in a given path
basically my code is ... (visual basic)
**Private Sub Populate(node As TreeNode, path As String)
Dim ftp = New FtpClient()
Try
ftp.Host = FTPSERVER
ftp.Credentials = New NetworkCredential(HidriveUs, HidrivePw)
ftp.AutoConnect()
For Each item As FtpListItem In ftp.GetListing(path)
' do filtering to discard non pdf files and pupulates the given node
Next
ftp.Disconnect()
Catch ex As Exception ' just in case
Mensaje.Text = "Se produjo un error al recuperar los archivos de " + path+ ": " + ex.Message
Finally
ftp.Dispose()
End Try
End Sub**
and that is working fine
After your answer, I've tried ...
**For Each item As FtpListItem In ftp.GetListing(path + "/*.pdf", FtpListOption.ForceList)**
but then I get nothing.
Just in case, I've also tried ...
**ftp.SetWorkingDirectory(path)
For Each item As FtpListItem In ftp.GetListing("*.pdf", FtpListOption.ForceList)**
getting nothing again
So far, I've started to believe my server doesn't allow wildcards.
So far, I've started to believe my server doesn't allow wildcards.
A log excerpt would tell us why...
but then I get nothing.
The answer of the server, the command selected by FluentFTP?
Note that some servers don't even like a path, you might need to go to the working directory first, and then do a listing using only the wildcard filespec + FtpListOption.NoPath as well.
So your second try needs:FtpListOption.ForceList | FtpListOption.NoPath
Once more this is a good example why adding some example code and log output to show what you are trying to do, would have been a good idea, to save some time in speculation.
In a (complete) log, we could also see the result of the FEAT command, tellings us about the capabilites of the server. Would make the discussion easier also.
If all else fails, your VBasic loop to select the right files is nothing other than what we would also do - so there is no real advantage in coding this inside GetListing, it is of course nice to have...
I've made a trial console app and use the Config.LogToConsole = true option.
LS: is not recognized
LIST is recognized but response nothing
MSLD without path or with a path that does not include wildcards works fine
MSLD with a path that includes wildcards responses nothing
I ended up acknowledging that I can't do the filtering at server side. I'll settle doing it at client side.
I've actually appreciate your kind support. Thank you so much.
Activity
robinrodricks commentedon Apr 13, 2023
Rules are a good idea, but keep in mind server will not do it. We do it on client side.
javiercoob commentedon Apr 14, 2023
Hi! Thanks for answering so soon.
About rules I supposed that was the problem.
However, as long as I know, wildcards do work in server side. Couldn't it be nice Getlisting implement that?
FanDjango commentedon Apr 14, 2023
I would like to chime in here, if I may.
RFC 959 (purposely?) does not go into any detail at all about the inferred meaning of filepath, pathname etc. when it describes the function of the LIST, RETR etc. etc. commands that take such a parameter.
Thus, in the past, different FTP (RFC 959) server implementations have taken various liberties in implementing wildcards, and to which degree.
The wildcard functionality that you can achieve today, currently depends entirely on the server that you are connecting to.
Here is an example, using an up-to-date ProFTPD server.
As you can see, on this server type,
MLSDwith wildcards is rejected.But:
If you code
you will get:
and the list items are populated correctly.
Therefore, I don't totally understand what you are asking for. Wildcards work, when the server supports them. You just need to find the right way to code it, and do some experiments to see what works and what does not.
If your wish is to support wildcards client-side, i.e. for servers that do not support them, then okay, that is a possibly valid enhancement request, although you can easily handle that in your own code.
FanDjango commentedon Apr 14, 2023
Once more this is a good example why adding some example code and log output to show what you are trying to do, would have been a good idea, to save some time in speculation.
It doesn't need to. The server does it. You just need to read up on GetListing and find out how to ask it to do the right thing.
javiercoob commentedon Apr 16, 2023
HI FanDjango. Thanks for your answer.
As first parameter in GetListing is path, I didn't think it was possible to add a wildcard.
So, I've been doing the filtering in client side.
My aim is to populate a treview node with the pdfs in a given path
basically my code is ... (visual basic)
**Private Sub Populate(node As TreeNode, path As String)
and that is working fine
After your answer, I've tried ...
but then I get nothing.
Just in case, I've also tried ...
getting nothing again
So far, I've started to believe my server doesn't allow wildcards.
FanDjango commentedon Apr 16, 2023
A log excerpt would tell us why...
The answer of the server, the command selected by FluentFTP?
Note that some servers don't even like a path, you might need to go to the working directory first, and then do a listing using only the wildcard filespec + FtpListOption.NoPath as well.
So your second try needs:
FtpListOption.ForceList | FtpListOption.NoPathFanDjango commentedon Apr 16, 2023
In a (complete) log, we could also see the result of the
FEATcommand, tellings us about the capabilites of the server. Would make the discussion easier also.FanDjango commentedon Apr 16, 2023
If all else fails, your VBasic loop to select the right files is nothing other than what we would also do - so there is no real advantage in coding this inside
GetListing, it is of course nice to have...javiercoob commentedon Apr 17, 2023
I've made a trial console app and use the Config.LogToConsole = true option.
LS: is not recognized
LIST is recognized but response nothing
MSLD without path or with a path that does not include wildcards works fine
MSLD with a path that includes wildcards responses nothing
I ended up acknowledging that I can't do the filtering at server side. I'll settle doing it at client side.
I've actually appreciate your kind support. Thank you so much.
FanDjango commentedon Apr 17, 2023
What about
NLST?[-]Asking for 'rules' or 'wildcards' in GetListing[/-][+]Implement 'rules' or 'wildcards' in GetListing[/+]FanDjango commentedon Apr 17, 2023
I have moved this to the Wiki: here
robinrodricks commentedon Apr 18, 2023
As I said before.
robinrodricks commentedon Apr 18, 2023
Thanks for your answer @FanDjango , added to FAQ - https://github.com/robinrodricks/FluentFTP/wiki/Directory-Listing#can-i-filter-file-listings-using-wildcards