필터 지우기
필터 지우기

Calling curl from within Matlab

조회 수: 38 (최근 30일)
Jonas_Carlson
Jonas_Carlson 2012년 9월 28일
답변: Michael McClung 2020년 10월 24일
I have a number of datafiles to be processed. They should be sent to a server, processed, with the results being further processed in Matlab.
I am using curl to communicate with the server using: reply = evalc('!curl https://... -H ... -d ...') and I get the result: curl: (1) Protocol https not supported or disabled in libcurl
I am using Matlab R2012a running under Linux (Fedora 17). When I try the exact same command in a terminal window, it works just fine. Also, this exact program worked before I upgraded Matlab from a previous version (2010).
As I need to use the -H and -d switches of curl I (think) I cannot use "urlread".
What is the difference between using curl in a terminal and invoking it via "!" or "system" from Matlab?
/Jonas Carlson
  댓글 수: 2
Scott
Scott 2013년 1월 4일
I've got the exact same problem on the exact same OS. I haven't fixed it yet but I can see there is a libcurl.so in /usr/local/MATLAB/R2012a/bin/glnxa64/ directory which is in LD_LIBRARY_PATH before the libcurl in /usr/lib64. This could have something to do with it.
Jonathan
Jonathan 2013년 7월 6일
I have the same problem. Has anyone found a fix? Thanks.

댓글을 달려면 로그인하십시오.

답변 (5개)

Christopher
Christopher 2013년 1월 5일
Can't you just use a system call?
[A,cURL_out] = system('curl http://www.google.com')
  댓글 수: 1
Walter Roberson
Walter Roberson 2013년 1월 5일
That would do the same thing as evalc('!curl...')

댓글을 달려면 로그인하십시오.


Pär Halje
Pär Halje 2013년 9월 5일
Hi
Apparently the version of libcurl that is bundled with Matlab does not support https. I found a somewhat cumbersome solution here:
This solution is written for Mac so you need to get your libcurl library from somewhere else than MacPort...
Or maybe libcurl is updated in a newer matlab version?
Pär

M. A. Hopcroft
M. A. Hopcroft 2013년 9월 17일
I had the same issue with Linux (Ubuntu) and R2012a, and solved it by changing the libcurl link in the MATLAB application libraries to point to the system libcurl.
The MATLAB application directory looks like this after installation:
/usr/local/MATLAB/R2012a/bin/glnxa64$ ll libcur*
lrwxrwxrwx 1 root root 16 2012-06-18 18:12 libcurl.so.4 -> libcurl.so.4.2.0*
-r-xr-xr-x 1 root root 320452 2011-12-29 00:33 libcurl.so.4.2.0*
The link in the system library directory is pointing to libcurl.so.4.1.1, which was built with https support:
/usr/lib$ ll libcurl*
lrwxrwxrwx 1 root root 19 2013-07-12 14:22 libcurl-gnutls.so.3 -> libcurl-gnutls.so.4
lrwxrwxrwx 1 root root 23 2013-07-12 14:22 libcurl-gnutls.so.4 -> libcurl-gnutls.so.4.1.1
-rw-r--r-- 1 root root 274368 2013-06-27 12:32 libcurl-gnutls.so.4.1.1
lrwxrwxrwx 1 root root 12 2013-07-12 14:22 libcurl.so.3 -> libcurl.so.4
lrwxrwxrwx 1 root root 16 2013-07-12 14:22 libcurl.so.4 -> libcurl.so.4.1.1
-rw-r--r-- 1 root root 295360 2013-06-27 12:32 libcurl.so.4.1.1
So I changed the softlink:
/usr/local/MATLAB/R2012a/bin/glnxa64$ sudo ln -s /usr/lib/libcurl.so.4.1.1 libcurl.so.4
This fixed the problem for me and has not caused any unintended consequences in MATLAB (so far).
>> system('curl -V')
curl 7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
Protocols: tftp ftp telnet dict ldap ldaps http file https ftps
Features: GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz

amjad majid
amjad majid 2015년 4월 21일
The way I solved this is as follows:
1- go to /Applications/MATLAB_R2015a.app/bin/maci64 2- rename libcurl.dylib to libcurl-OLD.dylib 3- rename libcurl.4.dylib to libcurl.4-OLD.dylib 5- make a symbolic link form to the libcurl from the operating system sudo ln -s /usr/lib/libcurl.4.dylib libcurl.4.dylib sudo ln -s /usr/lib/libcurl.dylib libcurl.dylib
Hopefully that would help

Michael McClung
Michael McClung 2020년 10월 24일
Another workaround is to prepend LD_LIBRARY_PATH="" in front of curl:
system('LD_LIBRARY_PATH="" && curl <args>')
This seems to work for me and does not require modification of installed MATLAB libraries.
On OSX this will probably need to replace LD_LIBRARY_PATH with DYLD_LIBRARY_PATH. However, I have no way to test.

카테고리

Help CenterFile Exchange에서 Introduction to Installation and Licensing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by