Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用SharpSSH以编程方式从SFTP服务器运行命令?_C#_.net_Sharpssh - Fatal编程技术网

C# 如何使用SharpSSH以编程方式从SFTP服务器运行命令?

C# 如何使用SharpSSH以编程方式从SFTP服务器运行命令?,c#,.net,sharpssh,C#,.net,Sharpssh,我用Tamir SharpSSH一切正常 但我需要用c代码运行命令 我把文件服务器,但我需要运行的作品有人知道这个命令 SshTransferProtocolBase sshCp; const string sftp_host = "xxx"; const string sftp_user = "xxx"; const string sftp_pass = "xxx"; const int sftp_port = 22; var sftp = new Sftp(sftp_host, sftp_u

我用Tamir SharpSSH一切正常 但我需要用c代码运行命令 我把文件服务器,但我需要运行的作品有人知道这个命令

SshTransferProtocolBase sshCp;
const string sftp_host = "xxx";
const string sftp_user = "xxx";
const string sftp_pass = "xxx";
const int sftp_port = 22;
var sftp = new Sftp(sftp_host, sftp_user, sftp_pass);
sftp.Connect(sftp_port);
sftp.Put(@"D:\\" + Teslim + ".txt", "../");
sftp.Close();

此代码正在运行我需要将命令运行到根目录中???

您不能通过FTP在远程服务器上执行代码。

您不能使用Sftp执行命令-您必须使用SSH控制台会话来运行命令。Tamir SharpSSH通过
SshExec
对象支持这一点

有关使用它的示例,请参见示例