Error using FTP mget function - File not found on server
Mostrar comentarios más antiguos
Hello everyone!
I've tried to use the mget function to get a file from a FTP server. It results in an error message that indicates that the file doesn't exist, but the file does exist. In fact, if I use the function delete with the same file name, it works properly, see the image below:

Furthermore, if I use mget(ftpobj,"*.txt"), it works and gets all the txt files, but if I use mget(ftpobj,"filename.txt") it does not work. I've also tried the mput function and it works well.
Has anyone experience this issue? Does anyone have a solution?
I've tried to see where the error is produced. Using the debugger in mget function, I've found that it calls the dir function in line 39:
[dirStruct, folderOrFile] = dir(obj, str);
This line outputs an empty dirStruct and folderOrFile = -1, which I guess it means a not found file.
But the problem is that if I open the dir function, I see that the second input argument is not a file name, but a folder name:
function varargout = dir(obj, folderName, options)
In fact, dir(obj) lists correctly the content.
Could it be the cause of the problem?
I appreciate any help to solve this problem.
2 comentarios
Steven Lord
hace alrededor de 1 hora
What do you see displayed when you ask MATLAB to show the raw output? Show at least the line containing the file that caused mget to throw the error and maybe one or two lines containing other files in that same folder (for comparison purposes).
files = dir(ftpobj, "ParseOutput", false)
The reason I'm asking is because I wonder if there's something odd going on with the permissions for that file, while the files variable created by the above line of code may show. Maybe you have write permissions to it (which I think would allow you to delete it) but not read permissions?
Walter Roberson
hace alrededor de 6 horas
Permission to delete a file requires write permission to the directory, but ignores permission on the files itself (unless there is an Access Control List established on the file.)
Permission to get the file requires read permission on the file itself.
Respuestas (1)
It would seem to be an issue if the internal dir function isn't returning the specific file, agreed. However, it seems peculiar if there's an issue in creating the arguments to be passed inside the mget function that it works with the wildcard string. From a debugging standpoint, it would be interesting and perhaps useful to see what are the specific values of those arguments for the two cases.
However, unless one were to create a local copy of the mget function and make a user-aliased version to make any code corrections, the present workaround solution would be to wrap the present function into a mymget.m file and have it return the full list and then select the one specific file wanted to return inside it.
I don't suppose you have an earlier release installed that you could test whether this is a newly-introduced issue with R2025x? The example in the doc seems to work here for either form...
s = ftp('ftp.ngdc.noaa.gov')
dir(s)
mget(s,'*.txt')
mget(s,'INDEX.txt')
ver
What OS/platform are you on?
Submit this to Mathworks as an official support request/bug at <Product Support Page>
Categorías
Más información sobre FTP File Operations en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!