shell command executed with "unix" fails in 2021a but works in 2017a

2 visualizzazioni (ultimi 30 giorni)
To download weather forcast files in grib format from NOAA I build a query like this:
unixstr = '/usr/bin/curl -k https://nomads.ncep.noaa.gov/pub/data/nccf/com/nam/prod/nam.20210831/nam.t00z.awip1200.tm00.grib2 --output nam.t00z.awip1200.tm00.grib2'
and run it with ...
unixstr(unixstr)
With version R2017a it works fine. With version 2021a I get an error:
curl: (48) An unknown option was passed in to libcurl
The status returned is 48.
Executing with ! or system it still fails.
Any suggestions on what is the problem, and what is the workaround?
  3 Commenti
John
John il 1 Set 2021
That was a typo, yes. I am executing ...
unix(unixstr)
Pounding on this some more with my local tech support we solved the problem. It is an issue with the libcurl library that ships with Matlab not matching the curl executable on the host. The workaround was to clear the LD_LIBRAY_PATH.
What we see, checking versions, is:
>> unix('/usr/bin/curl -V');
curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.72.0
which shows libcurl version 7.72.0 which is newer than the one on my local system (7.29.0).
I can clear that from the path by resetting LD_LIBRARY_PATH in my Matlab session, which then shows curl will use the older library matched to the executable:
>> unix('setenv LD_LIBRARY_PATH;/usr/bin/curl -V');
curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0 NSS/3.44
Putting it all together, I prepend the setenv LD_LIBRARY_PATH command to the curl command before I execute it, and I can see the file is downloading
>> unixstr = 'setenv LD_LIBRARY_PATH ;/usr/bin/curl -k https://nomads.ncep.noaa.gov/pub/data/nccf/com/nam/prod/nam.20210831/nam.t00z.awip1200.tm00.grib2 --output test.grib';
>> unix(unixstr);
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 28.2M 100 28.2M 0 0 9750k 0 0:00:02 0:00:02 --:--:-- 9749k
>>
John
John il 1 Set 2021
I've always wondered why the "unix" and "system" commands don't execute in the same shell environment that launched Matlab? That would be the intent of a user in issuing such a command.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Downloads in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by