Error using FTP mget function - File not found on server

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

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?
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.

Iniciar sesión para comentar.

Respuestas (1)

dpb
dpb hace alrededor de 2 horas
Movida: dpb hace alrededor de 1 hora
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')
FTP with properties: Host: "ftp.ngdc.noaa.gov" Username: "anonymous" Port: 21 ServerLocale: "en_US" DirParserFcn: @matlab.io.ftp.parseDirListingForUnix Mode: "binary" TLSMode: "none" LocalDataConnectionMethod: "passive" RemoteWorkingDirectory: "/" ConnectionTimeout: 5 min TransferTimeout: Inf min CertificateFilename: "default"
dir(s)
DMSP STP coastwatch geomag international pub INDEX.txt Snow_Ice dmsp4alan google12c4c939d7b90761.html ionosonde wdc README.txt Solid_Earth ftp.html index.html mgg
mget(s,'*.txt')
ans = 2×1 cell array
{'/users/mss.system.7r2dt/INDEX.txt' } {'/users/mss.system.7r2dt/README.txt'}
mget(s,'INDEX.txt')
ans = 1×1 cell array
{'/users/mss.system.7r2dt/INDEX.txt'}
ver
------------------------------------------------------------------------------------------------- MATLAB Version: 25.2.0.3150157 (R2025b) Update 4 MATLAB License Number: 40912989 Operating System: Linux 6.8.0-1024-aws #26~22.04.1-Ubuntu SMP Wed Feb 19 06:54:57 UTC 2025 x86_64 Java Version: Java 1.8.0_292-b10 with AdoptOpenJDK OpenJDK 64-Bit Server VM mixed mode ------------------------------------------------------------------------------------------------- MATLAB Version 25.2 (R2025b) Simulink Version 25.2 (R2025b) 5G Toolbox Version 25.2 (R2025b) Aerospace Blockset Version 25.2 (R2025b) Aerospace Toolbox Version 25.2 (R2025b) Antenna Toolbox Version 25.2 (R2025b) Audio Toolbox Version 25.2 (R2025b) Automated Driving Toolbox Version 25.2 (R2025b) Bioinformatics Toolbox Version 25.2 (R2025b) Bluetooth Toolbox Version 25.2 (R2025b) Communications Toolbox Version 25.2 (R2025b) Computer Vision Toolbox Version 25.2 (R2025b) Control System Toolbox Version 25.2 (R2025b) Curve Fitting Toolbox Version 25.2 (R2025b) DO Qualification Kit Version 25.2 (R2025b) DSP System Toolbox Version 25.2 (R2025b) Database Toolbox Version 25.2 (R2025b) Datafeed Toolbox Version 25.2 (R2025b) Deep Learning Toolbox Version 25.2 (R2025b) Econometrics Toolbox Version 25.2 (R2025b) Embedded Coder Version 25.2 (R2025b) Financial Instruments Toolbox Version 25.2 (R2025b) Financial Toolbox Version 25.2 (R2025b) Fixed-Point Designer Version 25.2 (R2025b) Fuzzy Logic Toolbox Version 25.2 (R2025b) Global Optimization Toolbox Version 25.2 (R2025b) HDL Coder Version 25.2 (R2025b) HDL Verifier Version 25.2 (R2025b) IEC Certification Kit Version 25.2 (R2025b) Image Acquisition Toolbox Version 25.2 (R2025b) Image Processing Toolbox Version 25.2 (R2025b) Industrial Communication Toolbox Version 25.2 (R2025b) Instrument Control Toolbox Version 25.2 (R2025b) LTE Toolbox Version 25.2 (R2025b) MATLAB Coder Version 25.2 (R2025b) MATLAB Compiler Version 25.2 (R2025b) MATLAB Compiler SDK Version 25.2 (R2025b) MATLAB Report Generator Version 25.2 (R2025b) Mapping Toolbox Version 25.2 (R2025b) Medical Imaging Toolbox Version 25.2 (R2025b) Mixed-Signal Blockset Version 25.2 (R2025b) Model Predictive Control Toolbox Version 25.2 (R2025b) Model-Based Calibration Toolbox Version 25.2 (R2025b) Navigation Toolbox Version 25.2 (R2025b) Optimization Toolbox Version 25.2 (R2025b) Parallel Computing Toolbox Version 25.2 (R2025b) Partial Differential Equation Toolbox Version 25.2 (R2025b) Phased Array System Toolbox Version 25.2 (R2025b) Powertrain Blockset Version 25.2 (R2025b) Predictive Maintenance Toolbox Version 25.2 (R2025b) RF Blockset Version 25.2 (R2025b) RF Toolbox Version 25.2 (R2025b) Radar Toolbox Version 25.2 (R2025b) Requirements Toolbox Version 25.2 (R2025b) Risk Management Toolbox Version 25.2 (R2025b) Robotics System Toolbox Version 25.2 (R2025b) Robust Control Toolbox Version 25.2 (R2025b) Sensor Fusion and Tracking Toolbox Version 25.2 (R2025b) SerDes Toolbox Version 25.2 (R2025b) Signal Processing Toolbox Version 25.2 (R2025b) SimBiology Version 25.2 (R2025b) SimEvents Version 25.2 (R2025b) Simscape Version 25.2 (R2025b) Simscape Driveline Version 25.2 (R2025b) Simscape Electrical Version 25.2 (R2025b) Simscape Fluids Version 25.2 (R2025b) Simscape Multibody Version 25.2 (R2025b) Simulink 3D Animation Version 25.2 (R2025b) Simulink Check Version 25.2 (R2025b) Simulink Code Inspector Version 25.2 (R2025b) Simulink Coder Version 25.2 (R2025b) Simulink Control Design Version 25.2 (R2025b) Simulink Coverage Version 25.2 (R2025b) Simulink Design Optimization Version 25.2 (R2025b) Simulink Design Verifier Version 25.2 (R2025b) Simulink Desktop Real-Time Version 25.2 (R2025b) Simulink PLC Coder Version 25.2 (R2025b) Simulink Real-Time Version 25.2 (R2025b) Simulink Report Generator Version 25.2 (R2025b) Simulink Test Version 25.2 (R2025b) Stateflow Version 25.2 (R2025b) Statistics and Machine Learning Toolbox Version 25.2 (R2025b) Symbolic Math Toolbox Version 25.2 (R2025b) System Identification Toolbox Version 25.2 (R2025b) Text Analytics Toolbox Version 25.2 (R2025b) Vehicle Dynamics Blockset Version 25.2 (R2025b) Vehicle Network Toolbox Version 25.2 (R2025b) Vision HDL Toolbox Version 25.2 (R2025b) WLAN Toolbox Version 25.2 (R2025b) Wavelet Toolbox Version 25.2 (R2025b) Wireless HDL Toolbox Version 25.2 (R2025b)
What OS/platform are you on?
Submit this to Mathworks as an official support request/bug at <Product Support Page>

Productos

Versión

R2025b

Etiquetas

Preguntada:

el 6 de Mzo. de 2026 a las 11:50

Comentada:

hace alrededor de 18 horas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by