檢視原始碼 ct_ftp (common_test v1.27.5)

FTP 客戶端模組(基於 ftp 應用程式)。

摘要

類型

參考已開啟的 FTP 連線,該連線與 handletarget_name 相關聯。

特定 FTP 連線的控制代碼,請參閱模組 ct

函式

變更遠端主機上的目錄。

關閉 FTP 連線。

刪除遠端主機上的檔案。

開啟 FTP 連線並從遠端主機取得檔案。

列出目錄 Dir

開啟與指定節點的 FTP 連線。

開啟 FTP 連線並將檔案傳送到遠端主機。

透過 FTP 取得檔案。

透過 FTP 取得檔案。

透過 FTP 傳送檔案。

透過 FTP 傳送檔案。

變更檔案傳輸類型。

類型

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

參考已開啟的 FTP 連線,該連線與 handletarget_name 相關聯。

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

特定 FTP 連線的控制代碼,請參閱模組 ct

函式

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

變更遠端主機上的目錄。

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

關閉 FTP 連線。

連結至此函式

delete(Connection, File)

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

刪除遠端主機上的檔案。

連結至此函式

get(KeyOrName, RemoteFile, LocalFile)

檢視原始碼
-spec get(KeyOrName, RemoteFile, LocalFile) -> ok | {error, Reason}
             when
                 KeyOrName :: ct:key_or_name(),
                 RemoteFile :: file:filename(),
                 LocalFile :: file:filename(),
                 Reason :: term().

開啟 FTP 連線並從遠端主機取得檔案。

RemoteFileLocalFile 必須是絕對路徑。

設定檔必須與 ct_ftp:put/3 的設定檔相同。

另請參閱 ct:require/2

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

列出目錄 Dir

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

開啟與指定節點的 FTP 連線。

您可以針對特定的 Name 開啟連線,並將相同的名稱用作所有後續操作的參考。如果您希望連線與 Handle 相關聯(例如,您需要開啟多個與主機的連線),請使用 Key,即組態變數名稱,來指定目標。沒有關聯目標名稱的連線只能使用控制代碼值關閉。

有關如何建立新的 Name 的資訊,請參閱 ct:require/2

連結至此函式

put(KeyOrName, LocalFile, RemoteFile)

檢視原始碼
-spec put(KeyOrName, LocalFile, RemoteFile) -> ok | {error, Reason}
             when
                 KeyOrName :: ct:key_or_name(),
                 LocalFile :: file:filename(),
                 RemoteFile :: file:filename(),
                 Reason :: term().

開啟 FTP 連線並將檔案傳送到遠端主機。

LocalFileRemoteFile 必須是絕對路徑。

如果目標主機是「特殊」節點,則 FTP 位址必須在設定檔中指定如下

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

如果目標主機是其他主機,例如 UNIX 主機,則設定檔也必須包含使用者名稱和密碼(均為字串)

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

另請參閱 ct:require/2

連結至此函式

recv(Connection, RemoteFile)

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

透過 FTP 取得檔案。

該檔案在本地主機上會取得相同的名稱。

另請參閱 ct_ftp:recv/3

連結至此函式

recv(Connection, RemoteFile, LocalFile)

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

透過 FTP 取得檔案。

該檔案在本地主機上命名為 LocalFile

連結至此函式

send(Connection, LocalFile)

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

透過 FTP 傳送檔案。

該檔案在遠端主機上會取得相同的名稱。

另請參閱 ct_ftp:send/3

連結至此函式

send(Connection, LocalFile, RemoteFile)

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

透過 FTP 傳送檔案。

該檔案在遠端主機上命名為 RemoteFile

連結至此函式

type(Connection, Type)

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

變更檔案傳輸類型。