0
當使用SharpSSh和SshExec類時,我無法使RunCommand正常工作,它始終返回一個空字符串。當我調試SharpSsh庫時,它在嘗試從流中讀取命令時返回-1。它在我在同一個庫中使用sftp類時起作用,但該類不支持我需要的所有ftp命令。SharpSSh:SshExec中的RunCommand始終返回一個空字符串
這是一個標準的例子,我不能讓這個產生正確的結果要麼
SshConnectionInfo input = Util.GetInput();
SshExec exec = new SshExec(input.Host, input.User);
if(input.Pass != null) exec.Password = input.Pass;
if(input.IdentityFile != null) exec.AddIdentityFile(input.IdentityFile);
Console.Write("Connecting...");
exec.Connect();
Console.WriteLine("OK");
while(true)
{
Console.Write("Enter a command to execute ['Enter' to cancel]: ");
string command = Console.ReadLine();
if(command=="")break;
string output = exec.RunCommand(command);
Console.WriteLine(output);
}
Console.Write("Disconnecting...");
exec.Close();
Console.WriteLine("OK");
我如何能得到RunCommand函數來運行一些命令任何想法? 感謝您的幫助:)