Discuss this help topic in SecureBlackbox Forum

Use command channel to send multiple commands with TElSimpleSSHClient

In the previous article you've learned how to execute one command with TElSimpleSSHClient. You can easily extend your configuration to launch several commands withing the same session.

Use Commands property to specify the list of commands to execute within the same session. The commands are executed in order, with each new one starting after the preceding one terminates. The first element of the Commands list (Commands[0]) maps to the Command property.

You have to set the commands before opening the connection.

C#:


client.Commands.Add("ls -l");
client.Commands.Add("touch ./test.bin");
client.Commands.Add("ls -l");

OnSendCommandRequest event is fired each time a new command from the list is sent. You can use this event to determine when the current command completes, in particular to read its return code via the ExitStatus property, or to separate incoming data.

How To articles about SSH client

Discuss this help topic in SecureBlackbox Forum