Error downloading .txt or .nc files through the ftp link
13 views (last 30 days)
Show older comments
By using the following function;
>> ftpobj = ftp('ftp://nrt.cmems-du.eu/Core/INSITU_GLO_NRT_OBSERVATIONS_013_030/glo_multiparameter_nrt/index_monthly.txt',username,password,'System','UNIX')
I am encountering with the error message, I reaaly appreciate any help.
Error using connect (line 18)
Could not open a connection to "ftp", port "NaN".
Error in ftp (line 75)
connect(h)
Thanks
1 Comment
Geoff Hayes
on 8 Jan 2020
Farshid - please see ftp host input parameter to get an idea of how the host should be constructed. You seem to be passing a link to a file rather than the name of the FTP server (with or without the port).
Answers (2)
Andrew Janke
on 31 Jan 2020
Geoff is right. You're passing a URL to ftp(), when it only accepts host names. You need to do the directory navigation and file selection in a separate step once you're connected. Try this:
remote_dir = 'Core/INSITU_GLO_NRT_OBSERVATIONS_013_030/glo_multiparameter_nrt';
remote_file = 'index_monthly.txt';
f = ftp('nrt.cmems-du.eu',username,password);
cd(f, remote_dir)
mget(f, remote_file)
7 Comments
Geoff Hayes
on 3 Feb 2020
Farshid - I modified your above comment to remove the host, username, and password from the code. I strongly recommend that you don't post such information on a public forum.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!