0 votes
by (2.0k points)

I want to get available and used disk space of sftp server.
I can not found related api on Rebex Sftp Client.
WinSCP shows disk space informations most of sftp servers.
How can I do?

Applies to: Rebex SFTP

1 Answer

+1 vote
by (72.7k points)
edited by
 
Best answer

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);
by (2.0k points)
Thank you very much.

I am already using 'df' command.
But some servers does not support this. (synology nas device,...)
So, Can I get your advice to implement SSH_FXP_EXTENDED function or statvfs@openssh.com extension using Rebex SFTP Client?
by (147k points)
Sorry for having to do the research for us! I'll edit our reply. We can add support for both "statvfs@openssh.com" (already widely supported) and for "space-available" (an alternative extension supported by server vendors who - unlike OpenSSH - choose to follow the SFTP v6 draft).
by (147k points)
edited by
Please e-mail us your licensing info to support@rebex.net, we'll send you a link to a beta when it's available.
by (147k points)
This feature has been added in version 2017 R6.1: https://rebex.net/total-pack/history.aspx#2017R6.1
by (2.0k points)
R6.1 works perfectly.
Thank you very much.
...