-
-
Notifications
You must be signed in to change notification settings - Fork 4
SSH.OpenChannel
Andrew Lambert edited this page Nov 26, 2022
·
12 revisions
SSH.OpenChannel
Protected Function OpenChannel(Session As SSH.Session, Type As String = "session", Message As String = "") As SSH.Channel
Protected Function OpenChannel(URL As String, KnownHostList As FolderItem = Nil, AddHost As Boolean = False) As SSH.Channel
Name | Type | Comment |
---|---|---|
Session |
SSH.Session | The active session to open a channel through. |
Type |
String | Optional. The SSH subsystem that the channel will be used for. |
Message |
String | Optional. The subsystem-defined message to send. |
Name | Type | Comment |
---|---|---|
URL |
String | A fully qualified URL to open as an SSH channel. |
KnownHostList |
FolderItem | Optional. A list of known hosts to check the server against. |
AddHost |
Boolean | Optional. Whether to add the server to the list of known hosts. |
On success returns an instance of SSH.Channel. On error either returns Nil
or raises an exception (see remarks.)
This convenience method opens a generic SSH channel to the remote server.
If an error occurs while opening the channel then the return value will be Nil
and the error details are stored in the Session
parameter (Session.LastError, etc.)
In an error occurs while establishing a new session and opening the channel then an SSHException will be raised.
This example starts a command ("uptime") on the remote machine and reads from its StdOut stream:
Dim sh As SSH.Channel = SSH.OpenChannel("ssh://user:[email protected]/")
Call sh.Execute("uptime")
Dim result As String
Do Until sh.EOF
If sh.PollReadable() Then
result = result + sh.Read(sh.BytesReadable, 0)
End If
Loop
sh.Close
- Channel.Open method
Wiki home | Project page | Bugs | Become a sponsor
Text and code examples are Copyright ©2018-24 Andrew Lambert, offered under the CC BY-SA 3.0 License.