36.4.1 FTP Objects

Octave supports the FTP protocol through an object-oriented interface. Use the function ftp to create an FTP object which represents the connection. All FTP functions take an FTP object as the first argument.

 
: f = ftp (host)
: f = ftp (host, username, password)

Connect to the FTP server host with username and password.

If username and password are not specified, user "anonymous" with no password is used. The returned FTP object f represents the established FTP connection.

The list of actions for an FTP object are shown below. All functions require an FTP object as the first argument.

MethodDescription
asciiSet transfer type to ascii
binarySet transfer type to binary
cdChange remote working directory
closeClose FTP connection
deleteDelete remote file
dirList remote directory contents
mgetDownload remote files
mkdirCreate remote directory
mputUpload local files
renameRename remote file or directory
rmdirRemove remote directory

See also: @ftp/ascii, @ftp/binary, @ftp/cd, @ftp/close, @ftp/delete, @ftp/dir, @ftp/mget, @ftp/mkdir, @ftp/mput, @ftp/rename, @ftp/rmdir.

 
: close (f)

Close the FTP connection represented by the FTP object f.

f is an FTP object returned by the ftp function.

See also: @ftp/ftp.

 
: mget (f, file)
: mget (f, dir)
: mget (f, remote_name, target)

Download a remote file file or directory dir to the local directory on the FTP connection f.

f is an FTP object returned by the ftp function.

The arguments file and dir can include wildcards and any files or directories on the remote server that match will be downloaded.

If a third string argument target is given, then it must indicate the path to the local destination directory. target may be a relative or absolute path.

See also: @ftp/mput, @ftp/ftp.

 
: mput (f, file)
: file_list = mput (f, file)

Upload the local file file into the current remote directory on the FTP connection f.

f is an FTP object returned by the ftp function.

The argument file is passed through the glob function and any files that match the wildcards in file will be uploaded.

The optional output argument file_list contains a cell array of strings with the names of the uploaded files.

See also: @ftp/mget, @ftp/mkdir, @ftp/ftp.

 
: cwd = cd (f)
: cd (f, path)
: new_cwd = cd (f, path)

Get or set the remote directory on the FTP connection f.

f is an FTP object returned by the ftp function.

If path is not specified, return the remote current working directory. Otherwise, set the remote directory to path and return the new remote working directory.

If the directory does not exist, an error message is printed and the working directory is not changed.

See also: @ftp/dir, @ftp/ftp.

 
: dir (f)
: lst = dir (f)

List the current directory in verbose form for the FTP connection f.

f is an FTP object returned by the ftp function.

If the optional output lst is requested return a struct array with one entry per file with the fields name, date, bytes, isdir, datenum.

See also: @ftp/cd, @ftp/mkdir, @ftp/rmdir, @ftp/ftp.

 
: ascii (f)

Set the FTP connection f to use ASCII mode for transfers.

ASCII mode is only appropriate for text files as it will convert the remote host’s newline representation to the local host’s newline representation.

f is an FTP object returned by the ftp function.

See also: @ftp/binary, @ftp/ftp.

 
: binary (f)

Set the FTP connection f to use binary mode for transfers.

In binary mode there is no conversion of newlines from the remote representation to the local representation.

f is an FTP object returned by the ftp function.

See also: @ftp/ascii, @ftp/ftp.

 
: delete (f, file)

Delete the remote file file over the FTP connection f.

f is an FTP object returned by the ftp function.

See also: @ftp/rmdir, @ftp/rename, @ftp/ftp.

 
: rename (f, oldname, newname)

Rename or move the remote file or directory oldname to newname, over the FTP connection f.

f is an FTP object returned by the ftp function.

See also: @ftp/delete, @ftp/rmdir, @ftp/ftp.

 
: mkdir (f, path)

Create the remote directory path, over the FTP connection f.

f is an FTP object returned by the ftp function.

See also: @ftp/rmdir, @ftp/ftp.

 
: rmdir (f, path)

Remove the remote directory path, over the FTP connection f.

f is an FTP object returned by the ftp function.

See also: @ftp/delete, @ftp/mkdir, @ftp/rename, @ftp/ftp.