Update: This has been added in version 2017 R6.1.
This feature is not part of SFTP protocol, but there are several common extensions for it. We will add support for this feature to one of the next releases of Rebex SFTP.
But until that release is available: Many SFTP servers make it possible to execute remote commands or start remote shell. You can use it to execute appropriate command from the client.
For example, if the SFTP server runs on Unix system, you can execute 'df
' command to get disk info.
How to do this with Rebex SFTP component is described here.
However, you can use Rebex Terminal Emulation component to do it simply like this:
// initialize SFTP object
Sftp client = new Sftp();
client.Connect(...);
client.Login(...);
// use SFTP commands
var items = client.GetList();
foreach (var item in items)
{
Console.WriteLine("{1}\t{2}\t{0}", item.Path, item.Type, item.Length);
}
// initialize SSH object (from SFTP session)
var ssh = new Ssh();
ssh.Bind(client.Session);
// execute SSH remote commands
var response = ssh.RunCommand("df");
Console.WriteLine(response);