ct_ftp(3)

πŸ“¦
version 29.0.6 Β· 3 versions
, in ubuntu stonking

✨ ct_ftp ✨

okay so bestie, welcome to ct_ftp, the Erlang module definition from the common_test manual, section 3 πŸ¦‹ β€” it's the FTP client module and yes it is based on the ftp application, no cap πŸ’…


πŸ’– DESCRIPTION πŸ’–

lowkey there's no prose here in the original, the description section just rolls straight into the data types, so like… vibe check passed, moving on πŸŽ€

πŸ¦‹ DATA TYPES πŸ¦‹

  • connection() :: handle() | ct:target_name() β€” this is a reference to an opened FTP connection, and it's associated with either a handle() or a target_name(). either one, she's flexible πŸ’β€β™€οΈ
  • handle() :: ct:handle() β€” the handle for one specific FTP connection, kthx, go check module ct for the deets 🫢

πŸŽ€ FUNCTIONS πŸŽ€

bestie real talk: every single one of these is deprecated, and the exact warning on each is "Legacy protocol support will be dropped in OTP-30". so like, they still work, but the clock is ticking, no cap πŸ’€

πŸ’… cd(Connection, Dir) -> ok | {error, Reason}

when
    Connection :: connection(),
    Dir :: file:filename(),
    Reason :: term().

Deprecated: ct_ftp:cd/2 is deprecated; Legacy protocol support will be dropped in OTP-30

Changes directory on the remote host. slay 🐚✨


πŸ’… close(Connection) -> ok | {error, Reason}

when Connection :: connection(), Reason :: term().

Deprecated: ct_ftp:close/1 is deprecated; Legacy protocol support will be dropped in OTP-30

Closes the FTP connection. bye bestie, door's that way πŸšͺπŸ‘‹


πŸ’… delete(Connection, File) -> ok | {error, Reason}

when
    Connection :: connection(),
    File :: file:filename(),
    Reason :: term().

Deprecated: ct_ftp:delete/2 is deprecated; Legacy protocol support will be dropped in OTP-30

Deletes a file on the remote host. gone, reduced to atoms πŸ’€πŸ—‘οΈ


πŸ’… get(KeyOrName, RemoteFile, LocalFile) -> ok | {error, Reason}

when
    KeyOrName :: ct:key_or_name(),
    RemoteFile :: file:filename(),
    LocalFile :: file:filename(),
    Reason :: term().

Deprecated: ct_ftp:get/3 is deprecated; Legacy protocol support will be dropped in OTP-30

Opens an FTP connection and fetches a file from the remote host. coming to your house 🏠πŸ“₯

  • RemoteFile and LocalFile must be absolute paths. no shortcuts, fr fr 🚫
  • The configuration file must be as for ct_ftp:put/3. (yes, go read that one, it's right down there πŸ‘‡)
  • See also ct:require/2.

πŸ’… ls(Connection, Dir) -> {ok, Listing} | {error, Reason}

when
    Connection :: connection(),
    Dir :: file:filename(),
    Listing :: string(),
    Reason :: term().

Deprecated: ct_ftp:ls/2 is deprecated; Legacy protocol support will be dropped in OTP-30

Lists directory Dir. it's giving window shopping πŸ›οΈβœ¨


πŸ’… open(KeyOrName) -> {ok, Handle} | {error, Reason}

when
    KeyOrName :: ct:key_or_name(),
    Handle :: handle(),
    Reason :: term().

Deprecated: ct_ftp:open/1 is deprecated; Legacy protocol support will be dropped in OTP-30

Opens an FTP connection to the specified node. πŸ”Œ

okay here's the tea 🍡 β€” you can open a connection for a particular Name and then use that same name as the reference for all your following subsequent operations. but if you'd rather the connection be associated with Handle instead (say, for example, you need to open multiple connections to a host πŸ‘€), then use Key, the configuration variable name, to specify the target. and heads up: a connection without an associated target name can only be closed with the handle value. that's the whole rule, periodt 🫑

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


πŸ’… put(KeyOrName, LocalFile, RemoteFile) -> ok | {error, Reason}

when
    KeyOrName :: ct:key_or_name(),
    LocalFile :: file:filename(),
    RemoteFile :: file:filename(),
    Reason :: term().

Deprecated: ct_ftp:put/3 is deprecated; Legacy protocol support will be dropped in OTP-30

Opens an FTP connection and sends a file to the remote host. πŸ“€ sending it, respectfully 😌

  • LocalFile and RemoteFile must be absolute paths. absolute paths only, we do not do relative here πŸ’…
  • If the target host is a "special" node, the FTP address must be specified in the configuration file like this:
{node,[{ftp,IpAddr}]}.
  • If the target host is something else, for example, a UNIX host, then the configuration file must also include the username and password, and both of those are strings:
{unix,[{ftp,IpAddr},
       {username,Username},
       {password,Password}]}.
  • See also ct:require/2.

πŸ’… recv(Connection, RemoteFile) -> ok | {error, Reason}

when
    Connection :: connection(),
    RemoteFile :: file:filename(),
    Reason :: term().

Deprecated: ct_ftp:recv/2 is deprecated; Legacy protocol support will be dropped in OTP-30

Fetches a file over FTP. πŸ“₯

The file gets the same name on the local host. twin energy 🧚

See also ct_ftp:recv/3. πŸ‘€


πŸ’… recv(Connection, RemoteFile, LocalFile) -> ok | {error, Reason}

when
    Connection :: connection(),
    RemoteFile :: file:filename(),
    LocalFile :: file:filename(),
    Reason :: term().

Deprecated: ct_ftp:recv/3 is deprecated; Legacy protocol support will be dropped in OTP-30

Fetches a file over FTP. πŸ“₯✨

This time the file is named LocalFile on the local host β€” you get to pick the name, main character behaviour πŸ‘‘


πŸ’… send(Connection, LocalFile) -> ok | {error, Reason}

when
    Connection :: connection(),
    LocalFile :: file:filename(),
    Reason :: term().

Deprecated: ct_ftp:send/2 is deprecated; Legacy protocol support will be dropped in OTP-30

Sends a file over FTP. πŸ“€

The file gets the same name on the remote host. same name, different machine, it's a long distance relationship 😭

See also ct_ftp:send/3. πŸ‘€


πŸ’… send(Connection, LocalFile, RemoteFile) -> ok | {error, Reason}

when
    Connection :: connection(),
    LocalFile :: file:filename(),
    RemoteFile :: file:filename(),
    Reason :: term().

Deprecated: ct_ftp:send/3 is deprecated; Legacy protocol support will be dropped in OTP-30

Sends a file over FTP. πŸ“€

The file is named RemoteFile on the remote host. you chose the name, iconic πŸŽ€


πŸ’… type(Connection, Type) -> ok | {error, Reason}

when
    Connection :: connection(),
    Type :: ascii | binary,
    Reason :: term().

Deprecated: ct_ftp:type/2 is deprecated; Legacy protocol support will be dropped in OTP-30

Changes the file transfer type. ascii or binary, pick your fighter πŸ₯Š


bestie we made it to the end 🫢 this absolute banger of a manual page comes to you from Ericsson AB, and it's common_test 1.31.1, ct_ftp(3). stan a legend, and go read ct:require/2 like I told you πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from