ct_ftp — common_test v1.27

Search documentation of common_test

# View Source ct_ftp (common_test v1.27)

FTP client module (based on the FTP application).

FTP client module (based on the `ftp` application).

# Summary

## Types

connection()

For `target_name`, see module `ct`.

handle()

Handle for a specific FTP connection, see module `ct`.

## Functions

cd(Connection, Dir)

Changes directory on remote host.

close(Connection)

Closes the FTP connection.

delete(Connection, File)

Deletes a file on remote host.

get(KeyOrName, RemoteFile, LocalFile)

Opens an FTP connection and fetches a file from the remote host.

ls(Connection, Dir)

Lists directory `Dir`.

open(KeyOrName)

Opens an FTP connection to the specified node.

put(KeyOrName, LocalFile, RemoteFile)

Opens an FTP connection and sends a file to the remote host.

recv(Connection, RemoteFile)

Fetches a file over FTP.

recv(Connection, RemoteFile, LocalFile)

Fetches a file over FTP.

send(Connection, LocalFile)

Sends a file over FTP.

send(Connection, LocalFile, RemoteFile)

Sends a file over FTP.

type(Connection, Type)

Changes the file transfer type.

# Types

Link to this type

# connection()

View Source

    -type connection() :: handle() | ct:target_name().

For `target_name`, see module `ct`.

Link to this type

# handle()

View Source

    -type handle() :: ct:handle().

Handle for a specific FTP connection, see module `ct`.

# Functions

Link to this function

# cd(Connection, Dir)

View Source

    -spec cd(Connection, Dir) -> ok | {error, Reason}
                when Connection :: connection(), Dir :: file:filename(), Reason :: term().

Changes directory on remote host.

Link to this function

# close(Connection)

View Source

    -spec close(Connection) -> ok | {error, Reason} when Connection :: connection(), Reason :: term().

Closes the FTP connection.

Link to this function

# delete(Connection, File)

View Source

    -spec delete(Connection, File) -> ok | {error, Reason}
                    when Connection :: connection(), File :: file:filename(), Reason :: term().

Deletes a file on remote host.

Link to this function

# get(KeyOrName, RemoteFile, LocalFile)

View Source

    -spec get(KeyOrName, RemoteFile, LocalFile) -> ok | {error, Reason}
                 when
                     KeyOrName :: atom(),
                     RemoteFile :: file:filename(),
                     LocalFile :: file:filename(),
                     Reason :: term().

Opens an FTP connection and fetches a file from the remote host.

`RemoteFile` and `LocalFile` must be absolute paths.

The configuration file must be as for `ct_ftp:put/3`.

For `target_name`, see module `ct`.

See also `ct:require/2`.

Link to this function

# ls(Connection, Dir)

View Source

    -spec ls(Connection, Dir) -> {ok, Listing} | {error, Reason}
                when
                    Connection :: connection(),
                    Dir :: file:filename(),
                    Listing :: string(),
                    Reason :: term().

Lists directory `Dir`.

Link to this function

# open(KeyOrName)

View Source

    -spec open(KeyOrName) -> {ok, Handle} | {error, Reason}
                  when KeyOrName :: atom(), Handle :: handle(), Reason :: term().

Opens an FTP connection to the specified node.

You can open a connection for a particular `Name` and use the same name as reference for all following subsequent operations. If you want the connection to be associated with `Handle` instead (if you, for example, need to open multiple connections to a host), use `Key`, the configuration variable name, to specify the target. A connection without an associated target name can only be closed with the handle value.

For information on how to create a new `Name`, see `ct:require/2`.

For `target_name`, see module `ct`.

Link to this function

# put(KeyOrName, LocalFile, RemoteFile)

View Source

    -spec put(KeyOrName, LocalFile, RemoteFile) -> ok | {error, Reason}
                 when
                     KeyOrName :: atom(),
                     LocalFile :: file:filename(),
                     RemoteFile :: file:filename(),
                     Reason :: term().

Opens an FTP connection and sends a file to the remote host.

`LocalFile` and `RemoteFile` must be absolute paths.

For `target_name`, see module `ct`.

If the target host is a "special" node, the FTP address must be specified in the configuration file as follows:

    {node,[{ftp,IpAddr}]}.

If the target host is something else, for example, a UNIX host, the configuration file must also include the username and password (both strings):

    {unix,[{ftp,IpAddr},
           {username,Username},
           {password,Password}]}.

See also `ct:require/2`.

Link to this function

# recv(Connection, RemoteFile)

View Source

    -spec recv(Connection, RemoteFile) -> ok | {error, Reason}
                  when Connection :: connection(), RemoteFile :: file:filename(), Reason :: term().

Fetches a file over FTP.

The file gets the same name on the local host.

See also `ct_ftp:recv/3`.

Link to this function

# recv(Connection, RemoteFile, LocalFile)

View Source

    -spec recv(Connection, RemoteFile, LocalFile) -> ok | {error, Reason}
                  when
                      Connection :: connection(),
                      RemoteFile :: file:filename(),
                      LocalFile :: file:filename(),
                      Reason :: term().

Fetches a file over FTP.

The file is named `LocalFile` on the local host.

Link to this function

# send(Connection, LocalFile)

View Source

    -spec send(Connection, LocalFile) -> ok | {error, Reason}
                  when Connection :: connection(), LocalFile :: file:filename(), Reason :: term().

Sends a file over FTP.

The file gets the same name on the remote host.

See also `ct_ftp:send/3`.

Link to this function

# send(Connection, LocalFile, RemoteFile)

View Source

    -spec send(Connection, LocalFile, RemoteFile) -> ok | {error, Reason}
                  when
                      Connection :: connection(),
                      LocalFile :: file:filename(),
                      RemoteFile :: file:filename(),
                      Reason :: term().

Sends a file over FTP.

The file is named `RemoteFile` on the remote host.

Link to this function

# type(Connection, Type)

View Source

    -spec type(Connection, Type) -> ok | {error, Reason}
                  when Connection :: connection(), Type :: ascii | binary, Reason :: term().

Changes the file transfer type.