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

SSH/SFTP 客戶端模組。

此模組使用應用程式 SSH,其中提供關於函式、類型和選項等詳細資訊。

SFTP 函式中的引數 Server 僅用於在現有的 SSH 連線上啟動的 SFTP 會話(也就是說,當原始連線類型為 ssh 時)。當連線類型為 sftp 時,僅使用 SSH 連線參考。

以下選項對於指定 SSH/SFTP 連線有效(也就是說,可以用作組態元素)

[{ConnType, Addr},
 {port, Port},
 {user, UserName}
 {password, Pwd}
 {user_dir, String}
 {public_key_alg, PubKeyAlg}
 {connect_timeout, Timeout}
 {key_cb, KeyCallbackMod}]

ConnType = ssh | sftp.

對於其他類型,請參閱 ssh

ct_ssh 函式中的所有逾時參數值都以毫秒為單位。

摘要

類型

已開啟的 SSH/SFTP 連線的參考,與 handletarget_name 相關聯。

用於連線的連線類型。

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

表示連線內部通道的資料類型。

有效值為 0 ("正常") 和 1 ("stderr"),請參閱 RFC 4254, Section 5.2

函式

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

使用與 KeyOrName 相關聯的資訊開啟 SSH 或 SFTP 連線(請參閱 connect/3)。

使用與 KeyOrName 相關聯的資訊開啟 SSH 或 SFTP 連線。

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

關閉 SSH/SFTP 連線。

要求伺服器執行 Command(請參閱 exec/4)。

要求伺服器執行 Command。先前開啟的會話通道用於請求。Data 會從伺服器接收,作為命令的結果。

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

在指定的會話通道上接收來自伺服器的預期資料(請參閱 receive_response/4)。

在指定的會話通道上接收來自伺服器的預期資料。

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

在指定的會話通道上將資料傳送到伺服器(請參閱 send/5)。

在指定的會話通道上將資料傳送到伺服器。

在指定的會話通道上將資料傳送到伺服器,並等待接收伺服器回應(請參閱 send_and_receive/6)。

在指定的會話通道上將資料傳送到伺服器,並等待接收伺服器回應(請參閱 send_and_receive/6)。

在指定的會話通道上將資料傳送到伺服器,並等待接收伺服器回應。

關閉 SSH 會話通道。

開啟 SSH 會話的通道。

在現有的 SSH 連線上啟動 SFTP 會話。Server 識別新的會話,並且每當要傳送 SFTP 請求時都必須指定。

要求使用者的預設 shell(通常在 Unix 系統的 /etc/passwd 中定義)在伺服器端執行。

傳送執行預定義子系統的請求。

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

如需資訊和其他類型,請參閱 ssh_sftp

類型

連結到此類型

connection()

檢視原始碼 (未匯出)
-type connection() :: handle() | ct:target_name().

已開啟的 SSH/SFTP 連線的參考,與 handletarget_name 相關聯。

連結到此類型

connection_type()

檢視原始碼 (未匯出)
-type connection_type() :: host | ssh | sftp.

用於連線的連線類型。

-type handle() :: pid().

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

連結到此類型

ssh_channel_id()

檢視原始碼 (未匯出)
-type ssh_channel_id() :: non_neg_integer().

表示連線內部通道的資料類型。

"如需 ssh_channel_id,請參閱模組 ssh。"。

連結到此類型

ssh_data_type_code()

檢視原始碼 (未匯出)
-type ssh_data_type_code() :: non_neg_integer().

有效值為 0 ("正常") 和 1 ("stderr"),請參閱 RFC 4254, Section 5.2

函式

連結到此函式

apread(SSH, Handle, Position, Length)

檢視原始碼
-spec apread(SSH, Handle, Position, Length) -> Result
                when
                    SSH :: connection(),
                    Handle :: term(),
                    Position :: integer(),
                    Length :: integer(),
                    Result :: {async, N} | {error, Reason},
                    N :: term(),
                    Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

apread(SSH, Server, Handle, Position, Length)

檢視原始碼
-spec apread(SSH, Server, Handle, Position, Length) -> Result
                when
                    SSH :: connection(),
                    Server :: pid(),
                    Handle :: term(),
                    Position :: integer(),
                    Length :: integer(),
                    Result :: {async, N} | {error, Reason},
                    N :: term(),
                    Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

apwrite(SSH, Handle, Position, Data)

檢視原始碼
-spec apwrite(SSH, Handle, Position, Data) -> Result
                 when
                     SSH :: connection(),
                     Handle :: term(),
                     Position :: integer(),
                     Data :: binary(),
                     Result :: {async, N} | {error, Reason},
                     N :: term(),
                     Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

apwrite(SSH, Server, Handle, Position, Data)

檢視原始碼
-spec apwrite(SSH, Server, Handle, Position, Data) -> Result
                 when
                     SSH :: connection(),
                     Server :: pid(),
                     Handle :: term(),
                     Position :: integer(),
                     Data :: binary(),
                     Result :: {async, N} | {error, Reason},
                     N :: term(),
                     Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

aread(SSH, Handle, Len)

檢視原始碼
-spec aread(SSH, Handle, Len) -> Result
               when
                   SSH :: connection(),
                   Handle :: term(),
                   Len :: integer(),
                   Result :: {async, N} | {error, Reason},
                   N :: term(),
                   Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

aread(SSH, Server, Handle, Len)

檢視原始碼
-spec aread(SSH, Server, Handle, Len) -> Result
               when
                   SSH :: connection(),
                   Server :: pid(),
                   Handle :: term(),
                   Len :: integer(),
                   Result :: {async, N} | {error, Reason},
                   N :: term(),
                   Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

awrite(SSH, Handle, Data)

檢視原始碼
-spec awrite(SSH, Handle, Data) -> Result
                when
                    SSH :: connection(),
                    Handle :: term(),
                    Data :: binary(),
                    Result :: {async, N} | {error, Reason},
                    N :: term(),
                    Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

awrite(SSH, Server, Handle, Data)

檢視原始碼
-spec awrite(SSH, Server, Handle, Data) -> Result
                when
                    SSH :: connection(),
                    Server :: pid(),
                    Handle :: term(),
                    Data :: binary(),
                    Result :: {async, N} | {error, Reason},
                    N :: term(),
                    Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

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

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

close(SSH, Server, Handle)

檢視原始碼
-spec close(SSH, Server, Handle) -> Result
               when
                   SSH :: connection(),
                   Server :: pid(),
                   Handle :: term(),
                   Result :: ok | {error, Reason},
                   Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

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

等同於 connect(KeyOrName, host, [])

-spec connect(KeyOrName, ConnType) -> {ok, Handle} | {error, Reason}
                 when
                     KeyOrName :: ct:key_or_name(),
                     ConnType :: connection_type(),
                     Handle :: handle(),
                     Reason :: term();
             (KeyOrName, ExtraOpts) -> {ok, Handle} | {error, Reason}
                 when
                     KeyOrName :: ct:key_or_name(),
                     ExtraOpts :: [ExtraOption],
                     ExtraOption ::
                         {ssh, Address} | {sftp, Address} | ssh:client_option() | ssh_sftp:sftp_option(),
                     Address :: ssh:host(),
                     Handle :: handle(),
                     Reason :: term().

使用與 KeyOrName 相關聯的資訊開啟 SSH 或 SFTP 連線(請參閱 connect/3)。

如果呼叫時 ConnType 為原子,則等同於 connect(KeyOrName, ConnType, [])

如果呼叫時 ExtraOpts 為清單,則等同於 connect(KeyOrName, host, ExtraOpts)

連結到此函式

connect(KeyOrName, ConnType, ExtraOpts)

檢視原始碼
-spec connect(KeyOrName, ConnType, ExtraOpts) -> {ok, Handle} | {error, Reason}
                 when
                     KeyOrName :: ct:key_or_name(),
                     ConnType :: connection_type(),
                     ExtraOpts :: [ExtraOption],
                     ExtraOption ::
                         {ssh, Address} | {sftp, Address} | ssh:client_option() | ssh_sftp:sftp_option(),
                     Address :: ssh:host(),
                     Handle :: handle(),
                     Reason :: term().

使用與 KeyOrName 相關聯的資訊開啟 SSH 或 SFTP 連線。

如果使用 NameKey 的別名)來識別連線,則此名稱可用作後續呼叫的連線參考。一次只能有一個與 Name 相關聯的開啟連線。如果使用 Key,則傳回的控制代碼必須用於後續呼叫(可以使用 Key 指定的組態資料開啟多個連線)。

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

ConnType 總是覆寫組態資料(和 ExtraOpts)中位址元組中指定的類型。因此,例如,可以使用最初指定 SSH 連線的資料直接開啟 SFTP 連線。值 host 表示使用主機選項指定的連線類型(無論是在組態資料中還是在 ExtraOpts 中)。

ExtraOpts (選用) 是要新增到 KeyOrName 組態資料的其他 SSH 選項。額外的選項會覆寫組態資料中具有相同索引鍵的任何現有選項。如需有關有效 SSH 選項的詳細資訊,請參閱應用程式 SSH

-spec del_dir(SSH, Name) -> Result
                 when
                     SSH :: connection(),
                     Name :: file:filename(),
                     Result :: ok | {error, Reason},
                     Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

del_dir(SSH, Server, Name)

檢視原始碼
-spec del_dir(SSH, Server, Name) -> Result
                 when
                     SSH :: connection(),
                     Server :: pid(),
                     Name :: file:filename(),
                     Result :: ok | {error, Reason},
                     Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

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

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

delete(SSH, Server, Name)

檢視原始碼
-spec delete(SSH, Server, Name) -> Result
                when
                    SSH :: connection(),
                    Server :: pid(),
                    Name :: file:filename(),
                    Result :: ok | {error, Reason},
                    Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

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

關閉 SSH/SFTP 連線。

-spec exec(SSH, Command) -> {ok, Data} | {timeout, Data} | {error, Reason}
              when SSH :: connection(), Command :: string(), Data :: string(), Reason :: term().

等同於 exec(SSH, Command, DefaultTimeout)

-spec exec(SSH, Command, Timeout) -> {ok, Data} | {timeout, Data} | {error, Reason}
              when
                  SSH :: connection(),
                  Command :: string(),
                  Timeout :: timeout(),
                  Data :: string(),
                  Reason :: term();
          (SSH, ChannelId, Command) -> {ok, Data} | {timeout, Data} | {error, Reason}
              when
                  SSH :: connection(),
                  ChannelId :: ssh_channel_id(),
                  Command :: string(),
                  Data :: string(),
                  Reason :: term().

要求伺服器執行 Command(請參閱 exec/4)。

如果呼叫時 Command 為字串,則等同於 exec(SSH, undefined, Command, Timeout)

如果呼叫時 ChannelId 為整數,則等同於 exec(SSH, ChannelId, Command, DefaultTimeout)

連結到此函式

exec(SSH, ChannelId, Command, Timeout)

檢視原始碼
-spec exec(SSH, ChannelId, Command, Timeout) -> {ok, Data} | {timeout, Data} | {error, Reason}
              when
                  SSH :: connection(),
                  ChannelId :: ssh_channel_id() | undefined,
                  Command :: string(),
                  Timeout :: timeout(),
                  Data :: string(),
                  Reason :: term().

要求伺服器執行 Command。先前開啟的會話通道用於請求。Data 會從伺服器接收,作為命令的結果。

連結到此函式

get_file_info(SSH, Handle)

檢視原始碼
-spec get_file_info(SSH, Handle) -> Result
                       when
                           SSH :: connection(),
                           Handle :: term(),
                           Result :: {ok, FileInfo} | {error, Reason},
                           FileInfo :: file:file_info(),
                           Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

get_file_info(SSH, Server, Handle)

檢視原始碼
-spec get_file_info(SSH, Server, Handle) -> Result
                       when
                           SSH :: connection(),
                           Server :: pid(),
                           Handle :: term(),
                           Result :: {ok, FileInfo} | {error, Reason},
                           FileInfo :: file:file_info(),
                           Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

-spec list_dir(SSH, Path) -> Result
                  when
                      SSH :: connection(),
                      Path :: file:filename(),
                      Result :: {ok, FileNames} | {error, Reason},
                      FileNames :: [FileName],
                      FileName :: file:filename(),
                      Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

list_dir(SSH, Server, Path)

檢視原始碼
-spec list_dir(SSH, Server, Path) -> Result
                  when
                      SSH :: connection(),
                      Server :: pid(),
                      Path :: file:filename(),
                      Result :: {ok, FileNames} | {error, Reason},
                      FileNames :: [FileName],
                      FileName :: file:filename(),
                      Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

-spec make_dir(SSH, Name) -> Result
                  when
                      SSH :: connection(),
                      Name :: file:filename(),
                      Result :: ok | {error, Reason},
                      Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

make_dir(SSH, Server, Name)

檢視原始碼
-spec make_dir(SSH, Server, Name) -> Result
                  when
                      SSH :: connection(),
                      Server :: pid(),
                      Name :: file:filename(),
                      Result :: ok | {error, Reason},
                      Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

make_symlink(SSH, Name, Target)

檢視原始碼
-spec make_symlink(SSH, Name, Target) -> Result
                      when
                          SSH :: connection(),
                          Name :: file:filename(),
                          Target :: file:filename(),
                          Result :: ok | {error, Reason},
                          Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

make_symlink(SSH, Server, Name, Target)

檢視原始碼
-spec make_symlink(SSH, Server, Name, Target) -> Result
                      when
                          SSH :: connection(),
                          Server :: pid(),
                          Name :: file:filename(),
                          Target :: file:filename(),
                          Result :: ok | {error, Reason},
                          Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

-spec open(SSH, File, Mode) -> Result
              when
                  SSH :: connection(),
                  File :: file:filename(),
                  Mode :: [read | write | append | binary | raw],
                  Result :: {ok, Handle} | {error, Reason},
                  Handle :: term(),
                  Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

open(SSH, Server, File, Mode)

檢視原始碼
-spec open(SSH, Server, File, Mode) -> Result
              when
                  SSH :: connection(),
                  Server :: pid(),
                  File :: file:filename(),
                  Mode :: [read | write | append | binary | raw],
                  Result :: {ok, Handle} | {error, Reason},
                  Handle :: term(),
                  Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

-spec opendir(SSH, Path) -> Result
                 when
                     SSH :: connection(),
                     Path :: file:filename(),
                     Result :: {ok, Handle} | {error, Reason},
                     Handle :: term(),
                     Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

opendir(SSH, Server, Path)

檢視原始碼
-spec opendir(SSH, Server, Path) -> Result
                 when
                     SSH :: connection(),
                     Server :: pid(),
                     Path :: file:filename(),
                     Result :: {ok, Handle} | {error, Reason},
                     Handle :: term(),
                     Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

position(SSH, Handle, Location)

檢視原始碼
-spec position(SSH, Handle, Location) -> Result
                  when
                      SSH :: connection(),
                      Handle :: term(),
                      Location ::
                          Offset | {bof, Offset} | {cur, Offset} | {eof, Offset} | bof | cur | eof,
                      Offset :: integer(),
                      Result :: {ok, NewPosition} | {error, Reason},
                      NewPosition :: integer(),
                      Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

position(SSH, Server, Handle, Location)

檢視原始碼
-spec position(SSH, Server, Handle, Location) -> Result
                  when
                      SSH :: connection(),
                      Server :: pid(),
                      Handle :: term(),
                      Location ::
                          Offset | {bof, Offset} | {cur, Offset} | {eof, Offset} | bof | cur | eof,
                      Offset :: integer(),
                      Result :: {ok, NewPosition} | {error, Reason},
                      NewPosition :: integer(),
                      Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

pread(SSH, Handle, Position, Length)

檢視原始碼
-spec pread(SSH, Handle, Position, Length) -> Result
               when
                   SSH :: connection(),
                   Handle :: term(),
                   Position :: integer(),
                   Length :: integer(),
                   Result :: {ok, Data} | eof | {error, Reason},
                   Data :: string() | binary(),
                   Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

pread(SSH, Server, Handle, Position, Length)

檢視原始碼
-spec pread(SSH, Server, Handle, Position, Length) -> Result
               when
                   SSH :: connection(),
                   Server :: pid(),
                   Handle :: term(),
                   Position :: integer(),
                   Length :: integer(),
                   Result :: {ok, Data} | eof | {error, Reason},
                   Data :: string() | binary(),
                   Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

pwrite(SSH, Handle, Position, Data)

檢視原始碼
-spec pwrite(SSH, Handle, Position, Data) -> Result
                when
                    SSH :: connection(),
                    Handle :: term(),
                    Position :: integer(),
                    Data :: iolist(),
                    Result :: ok | {error, Reason},
                    Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

pwrite(SSH, Server, Handle, Position, Data)

檢視原始碼
-spec pwrite(SSH, Server, Handle, Position, Data) -> Result
                when
                    SSH :: connection(),
                    Server :: pid(),
                    Handle :: term(),
                    Position :: integer(),
                    Data :: iolist(),
                    Result :: ok | {error, Reason},
                    Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

read(SSH, Handle, Len)

檢視原始碼
-spec read(SSH, Handle, Len) -> Result
              when
                  SSH :: connection(),
                  Handle :: term(),
                  Len :: integer(),
                  Result :: {ok, Data} | eof | {error, Reason},
                  Data :: string() | binary(),
                  Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

read(SSH, Server, Handle, Len)

檢視原始碼
-spec read(SSH, Server, Handle, Len) -> Result
              when
                  SSH :: connection(),
                  Server :: pid(),
                  Handle :: term(),
                  Len :: integer(),
                  Result :: {ok, Data} | eof | {error, Reason},
                  Data :: string() | binary(),
                  Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

-spec read_file(SSH, File) -> Result
                   when
                       SSH :: connection(),
                       File :: file:filename(),
                       Result :: {ok, Data} | {error, Reason},
                       Data :: binary(),
                       Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

read_file(SSH, Server, File)

檢視原始碼
-spec read_file(SSH, Server, File) -> Result
                   when
                       SSH :: connection(),
                       Server :: pid(),
                       File :: file:filename(),
                       Result :: {ok, Data} | {error, Reason},
                       Data :: binary(),
                       Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

read_file_info(SSH, Name)

檢視原始碼
-spec read_file_info(SSH, Name) -> Result
                        when
                            SSH :: connection(),
                            Name :: file:filename(),
                            Result :: {ok, FileInfo} | {error, Reason},
                            FileInfo :: file:file_info(),
                            Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

read_file_info(SSH, Server, Name)

檢視原始碼
-spec read_file_info(SSH, Server, Name) -> Result
                        when
                            SSH :: connection(),
                            Server :: pid(),
                            Name :: file:filename(),
                            Result :: {ok, FileInfo} | {error, Reason},
                            FileInfo :: file:file_info(),
                            Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

-spec read_link(SSH, Name) -> Result
                   when
                       SSH :: connection(),
                       Name :: file:filename(),
                       Result :: {ok, Target} | {error, Reason},
                       Target :: file:filename(),
                       Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

read_link(SSH, Server, Name)

檢視原始碼
-spec read_link(SSH, Server, Name) -> Result
                   when
                       SSH :: connection(),
                       Server :: pid(),
                       Name :: file:filename(),
                       Result :: {ok, Target} | {error, Reason},
                       Target :: file:filename(),
                       Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

receive_response(SSH, ChannelId)

檢視原始碼
-spec receive_response(SSH, ChannelId) -> {ok, Data} | {timeout, Data} | {error, Reason}
                          when
                              SSH :: connection(),
                              ChannelId :: ssh_channel_id(),
                              Data :: string(),
                              Reason :: term().

等同於 receive_response(SSH, ChannelId, close, DefaultTimeout)

-spec receive_response(SSH, ChannelId, End) -> {ok, Data} | {timeout, Data} | {error, Reason}
                          when
                              SSH :: connection(),
                              ChannelId :: ssh_channel_id(),
                              End :: fun((string()) -> boolean()),
                              Data :: string(),
                              Reason :: term();
                      (SSH, ChannelId, Timeout) -> {ok, Data} | {timeout, Data} | {error, Reason}
                          when
                              SSH :: connection(),
                              ChannelId :: ssh_channel_id(),
                              Timeout :: timeout(),
                              Data :: string(),
                              Reason :: term().

在指定的會話通道上接收來自伺服器的預期資料(請參閱 receive_response/4)。

如果呼叫時 End 為函式,則等同於 receive_response(SSH, ChannelId, End, DefaultTimeout)

如果呼叫時 Timeout 為整數,則等同於 receive_response(SSH, ChannelId, close, Timeout)

連結到此函式

receive_response(SSH, ChannelId, End, Timeout)

檢視原始碼
-spec receive_response(SSH, ChannelId, End, Timeout) -> {ok, Data} | {timeout, Data} | {error, Reason}
                          when
                              SSH :: connection(),
                              ChannelId :: ssh_channel_id(),
                              End :: close | timeout | fun((string()) -> boolean()),
                              Timeout :: timeout(),
                              Data :: string(),
                              Reason :: term().

在指定的會話通道上接收來自伺服器的預期資料。

如果 End == close,則當伺服器關閉通道時,資料會傳回給呼叫者。如果在發生這種情況之前發生逾時,則函式會傳回 {timeout,Data}(其中 Data 是目前為止收到的資料)。

如果 End == timeout,則預期會發生逾時,並且在發生逾時和關閉通道時都會傳回 {ok,Data}

如果 End 是一個函式,則此函式會被調用,並帶有一個參數,即接收到的 ssh_cm 訊息中的資料值(請參閱 ssh_connection)。此函式必須返回 true 以結束接收操作(並傳回目前收集到的資料),或返回 false 以等待伺服器傳送更多資料。即使提供了函式,如果伺服器關閉通道,此函式也會立即返回)。

連結到此函式

rename(SSH, OldName, NewName)

檢視原始碼
-spec rename(SSH, OldName, NewName) -> Result
                when
                    SSH :: connection(),
                    OldName :: file:filename(),
                    NewName :: file:filename(),
                    Result :: ok | {error, Reason},
                    Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

rename(SSH, Server, OldName, NewName)

檢視原始碼
-spec rename(SSH, Server, OldName, NewName) -> Result
                when
                    SSH :: connection(),
                    Server :: pid(),
                    OldName :: file:filename(),
                    NewName :: file:filename(),
                    Result :: ok | {error, Reason},
                    Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

send(SSH, ChannelId, Data)

檢視原始碼
-spec send(SSH, ChannelId, Data) -> ok | {error, Reason}
              when
                  SSH :: connection(), ChannelId :: ssh_channel_id(), Data :: iodata(), Reason :: term().

等同於 send(SSH, ChannelId, 0, Data, DefaultTimeout)

-spec send(SSH, ChannelId, Data, Timeout) -> ok | {error, Reason}
              when
                  SSH :: connection(),
                  ChannelId :: ssh_channel_id(),
                  Data :: iodata(),
                  Timeout :: timeout(),
                  Reason :: term();
          (SSH, ChannelId, Type, Data) -> ok | {error, Reason}
              when
                  SSH :: connection(),
                  ChannelId :: ssh_channel_id(),
                  Type :: ssh_data_type_code(),
                  Data :: iodata(),
                  Reason :: term().

在指定的會話通道上將資料傳送到伺服器(請參閱 send/5)。

等同於使用整數 Timeout 呼叫 send(SSH, ChannelId, 0, Data, Timeout)

等同於使用整數 Type 呼叫 send(SSH, ChannelId, Type, Data, DefaultTimeout)

連結到此函式

send(SSH, ChannelId, Type, Data, Timeout)

檢視原始碼
-spec send(SSH, ChannelId, Type, Data, Timeout) -> ok | {error, Reason}
              when
                  SSH :: connection(),
                  ChannelId :: ssh_channel_id(),
                  Type :: ssh_data_type_code(),
                  Data :: iodata(),
                  Timeout :: timeout(),
                  Reason :: term().

在指定的會話通道上將資料傳送到伺服器。

連結到此函式

send_and_receive(SSH, ChannelId, Data)

檢視原始碼
-spec send_and_receive(SSH, ChannelId, Data) ->
                          {ok, ReceivedData} | {timeout, ReceivedData} | {error, Reason}
                          when
                              SSH :: connection(),
                              ChannelId :: ssh_channel_id(),
                              Data :: iodata(),
                              ReceivedData :: string(),
                              Reason :: term().

等同於 send_and_receive(SSH, ChannelId, 0, Data, close, DefaultTimeout)

-spec send_and_receive(SSH, ChannelId, Data, End) ->
                          {ok, ReceivedData} | {timeout, ReceivedData} | {error, Reason}
                          when
                              SSH :: connection(),
                              ChannelId :: ssh_channel_id(),
                              Data :: iodata(),
                              End :: close | timeout | fun((string()) -> boolean()),
                              ReceivedData :: string(),
                              Reason :: term();
                      (SSH, ChannelId, Data, Timeout) ->
                          {ok, ReceivedData} | {timeout, ReceivedData} | {error, Reason}
                          when
                              SSH :: connection(),
                              ChannelId :: ssh_channel_id(),
                              Data :: iodata(),
                              Timeout :: timeout(),
                              ReceivedData :: string(),
                              Reason :: term();
                      (SSH, ChannelId, Type, Data) ->
                          {ok, ReceivedData} | {timeout, ReceivedData} | {error, Reason}
                          when
                              SSH :: connection(),
                              ChannelId :: ssh_channel_id(),
                              Type :: ssh_data_type_code(),
                              Data :: iodata(),
                              ReceivedData :: string(),
                              Reason :: term().

在指定的會話通道上將資料傳送到伺服器,並等待接收伺服器回應(請參閱 send_and_receive/6)。

等同於使用函式 End 呼叫 send_and_receive(SSH, ChannelId, 0, Data, End, DefaultTimeout)

等同於使用整數 Timeout 呼叫 send_and_receive(SSH, ChannelId, 0, Data, close, Timeout)

等同於使用整數 Type 呼叫 send_and_receive(SSH, ChannelId, Type, Data, close, DefaultTimeout)

-spec send_and_receive(SSH, ChannelId, Data, End, Timeout) ->
                          {ok, ReceivedData} | {timeout, Data} | {error, Reason}
                          when
                              SSH :: connection(),
                              ChannelId :: ssh_channel_id(),
                              Data :: iodata(),
                              End :: close | timeout | fun((string()) -> boolean()),
                              Timeout :: timeout(),
                              ReceivedData :: string(),
                              Reason :: term();
                      (SSH, ChannelId, Type, Data, Timeout) ->
                          {ok, ReceivedData} | {timeout, ReceivedData} | {error, Reason}
                          when
                              SSH :: connection(),
                              ChannelId :: ssh_channel_id(),
                              Type :: ssh_data_type_code(),
                              Data :: iodata(),
                              Timeout :: timeout(),
                              ReceivedData :: string(),
                              Reason :: term();
                      (SSH, ChannelId, Type, Data, End) ->
                          {ok, ReceivedData} | {timeout, ReceivedData} | {error, Reason}
                          when
                              SSH :: connection(),
                              ChannelId :: ssh_channel_id(),
                              Type :: ssh_data_type_code(),
                              Data :: iodata(),
                              End :: close | timeout | fun((string()) -> boolean()),
                              ReceivedData :: string(),
                              Reason :: term().

在指定的會話通道上將資料傳送到伺服器,並等待接收伺服器回應(請參閱 send_and_receive/6)。

等同於使用整數 Timeout 呼叫 send_and_receive(SSH, ChannelId, 0, Data, End, Timeout)

等同於使用整數 Type 呼叫 send_and_receive(SSH, ChannelId, Type, Data, close, Timeout)

等同於使用函式 End 呼叫 send_and_receive(SSH, ChannelId, Type, Data, End, DefaultTimeout)

連結到此函式

send_and_receive(SSH, ChannelId, Type, Data, End, Timeout)

檢視原始碼
-spec send_and_receive(SSH, ChannelId, Type, Data, End, Timeout) ->
                          {ok, ReceivedData} | {timeout, ReceivedData} | {error, Reason}
                          when
                              SSH :: connection(),
                              ChannelId :: ssh_channel_id(),
                              Type :: ssh_data_type_code(),
                              Data :: iodata(),
                              End :: close | timeout | fun((string()) -> boolean()),
                              Timeout :: timeout(),
                              ReceivedData :: string(),
                              Reason :: term().

在指定的會話通道上將資料傳送到伺服器,並等待接收伺服器回應。

有關參數 End 的詳細資訊,請參閱 ct_ssh:receive_response/4

連結到此函式

session_close(SSH, ChannelId)

檢視原始碼
-spec session_close(SSH, ChannelId) -> ok | {error, Reason}
                       when SSH :: connection(), ChannelId :: ssh_channel_id(), Reason :: term().

關閉 SSH 會話通道。

-spec session_open(SSH) -> {ok, ChannelId} | {error, Reason}
                      when SSH :: connection(), ChannelId :: ssh_channel_id(), Reason :: term().

等同於 session_open(SSH, DefaultTimeout)

連結到此函式

session_open(SSH, Timeout)

檢視原始碼
-spec session_open(SSH, Timeout) -> {ok, ChannelId} | {error, Reason}
                      when
                          SSH :: connection(),
                          Timeout :: timeout(),
                          ChannelId :: ssh_channel_id(),
                          Reason :: term().

開啟 SSH 會話的通道。

-spec sftp_connect(SSH) -> {ok, Server} | {error, Reason}
                      when SSH :: connection(), Server :: pid(), Reason :: term().

在現有的 SSH 連線上啟動 SFTP 會話。Server 識別新的會話,並且每當要傳送 SFTP 請求時都必須指定。

連結到此函式

shell(SSH, ChannelId)

檢視原始碼 (自 OTP 20.0 起)
-spec shell(SSH, ChannelId) -> Result
               when
                   SSH :: connection(),
                   ChannelId :: ssh:ssh_channel_id(),
                   Result :: ok | {error, term()}.

等同於 shell(SSH, ChannelId, DefaultTimeout)

連結到此函式

shell(SSH, ChannelId, Timeout)

檢視原始碼 (自 OTP 20.0 起)
-spec shell(SSH, ChannelId, Timeout) -> Result
               when
                   SSH :: connection(),
                   ChannelId :: ssh:ssh_channel_id(),
                   Timeout :: timeout(),
                   Result :: ok | {error, term()}.

要求使用者的預設 shell(通常在 Unix 系統的 /etc/passwd 中定義)在伺服器端執行。

連結到此函式

subsystem(SSH, ChannelId, Subsystem)

檢視原始碼
-spec subsystem(SSH, ChannelId, Subsystem) -> Status | {error, Reason}
                   when
                       SSH :: connection(),
                       ChannelId :: ssh_channel_id(),
                       Subsystem :: string(),
                       Status :: success | failure,
                       Reason :: term().

等同於 subsystem(SSH, Channel, Subsystem, DefaultTimeout)

連結到此函式

subsystem(SSH, ChannelId, Subsystem, Timeout)

檢視原始碼
-spec subsystem(SSH, ChannelId, Subsystem, Timeout) -> Status | {error, Reason}
                   when
                       SSH :: connection(),
                       ChannelId :: ssh_channel_id(),
                       Subsystem :: string(),
                       Timeout :: timeout(),
                       Status :: success | failure,
                       Reason :: term().

傳送執行預定義子系統的請求。

連結到此函式

write(SSH, Handle, Data)

檢視原始碼
-spec write(SSH, Handle, Data) -> Result
               when
                   SSH :: connection(),
                   Handle :: term(),
                   Data :: iodata(),
                   Result :: ok | {error, Reason},
                   Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

write(SSH, Server, Handle, Data)

檢視原始碼
-spec write(SSH, Server, Handle, Data) -> Result
               when
                   SSH :: connection(),
                   Server :: pid(),
                   Handle :: term(),
                   Data :: iodata(),
                   Result :: ok | {error, Reason},
                   Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

write_file(SSH, File, Iolist)

檢視原始碼
-spec write_file(SSH, File, Iolist) -> Result
                    when
                        SSH :: connection(),
                        File :: file:filename(),
                        Iolist :: iodata(),
                        Result :: ok | {error, Reason},
                        Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

write_file(SSH, Server, File, Iolist)

檢視原始碼
-spec write_file(SSH, Server, File, Iolist) -> Result
                    when
                        SSH :: connection(),
                        Server :: pid(),
                        File :: file:filename(),
                        Iolist :: iodata(),
                        Result :: ok | {error, Reason},
                        Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

write_file_info(SSH, Name, Info)

檢視原始碼
-spec write_file_info(SSH, Name, Info) -> Result
                         when
                             SSH :: connection(),
                             Name :: file:filename(),
                             Info :: file:file_info(),
                             Result :: ok | {error, Reason},
                             Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp

連結到此函式

write_file_info(SSH, Server, Name, Info)

檢視原始碼
-spec write_file_info(SSH, Server, Name, Info) -> Result
                         when
                             SSH :: connection(),
                             Server :: pid(),
                             Name :: file:filename(),
                             Info :: file:file_info(),
                             Result :: ok | {error, Reason},
                             Reason :: term().

如需資訊和其他類型,請參閱 ssh_sftp