SharpSShとSshExecクラスを使用すると、RunCommandを機能させることができず、常に空の文字列が返されます。SharpSshライブラリをデバッグすると、ストリームからコマンドを読み取ろうとすると-1が返されます。同じライブラリでsftpクラスを使用すると機能しますが、そのクラスは必要なすべてのftpコマンドをサポートしているわけではありません。
これが標準的な例です。これを取得して正しい結果を生成することもできません
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関数でいくつかのコマンドを実行する方法について何かアイデアはありますか?助けてくれてありがとう:)