- publishing free software manuals
GNU Octave Manual Version 3
by John W. Eaton, David Bateman, Søren Hauberg
Paperback (6"x9"), 568 pages
ISBN 095461206X
RRP £24.95 ($39.95)

Get a printed copy>>>

32.4 Networking Utilities

Loadable Function: s = urlread (url)
Loadable Function: [s, success] = urlread (url)
Loadable Function: [s, success, message] = urlread (url)
Loadable Function: [...] = urlread (url, method, param)
Download a remote file specified by its URL and return its content in string s. For example,

s = urlread ("ftp://ftp.octave.org/pub/octave/README");

The variable success is 1 if the download was successful, otherwise it is 0 in which case message contains an error message. If no output argument is specified and if an error occurs, then the error is signaled through Octave's error handling mechanism.

This function uses libcurl. Curl supports, among others, the HTTP, FTP and FILE protocols. Username and password may be specified in the URL. For example,

s = urlread ("http://user:[email protected]/file.txt");

GET and POST requests can be specified by method and param. The parameter method is either ‘get’ or ‘post’ and param is a cell array of parameter and value pairs. For example,

s = urlread ("http://www.google.com/search", "get",
             {"query", "octave"});

See also urlwrite

Loadable Function: urlwrite (URL, localfile)
Loadable Function: f = urlwrite (url, localfile)
Loadable Function: [f, success] = urlwrite (url, localfile)
Loadable Function: [f, success, message] = urlwrite (url, localfile)
Download a remote file specified by its URL and save it as localfile. For example,

urlwrite ("ftp://ftp.octave.org/pub/octave/README", 
          "README.txt");

The full path of the downloaded file is returned in f. The variable success is 1 if the download was successful, otherwise it is 0 in which case message contains an error message. If no output argument is specified and if an error occurs, then the error is signaled through Octave's error handling mechanism.

This function uses libcurl. Curl supports, among others, the HTTP, FTP and FILE protocols. Username and password may be specified in the URL, for example:

urlwrite ("http://username:[email protected]/file.txt",
          "file.txt");

GET and POST requests can be specified by method and param. The parameter method is either ‘get’ or ‘post’ and param is a cell array of parameter and value pairs. For example:

urlwrite ("http://www.google.com/search", "search.html",
          "get", {"query", "octave"});

See also urlread

ISBN 095461206XGNU Octave Manual Version 3See the print edition