大家好我已经尝试过SharpSSH执行unix命令到目前为止每件事都运行正常,除非我无法将用户选择传递给远程PC,例如我运行了一个命令,如"执行一些菜单"作为回应,我将获得菜单提示我输入选择,但我不能简单地通过这个选择,任何帮助将非常感谢。
try
{
SshExec exec = new SshExec("somehost", "someuser");
exec.Password = "somepass";
//if (input.IdentityFile != null) exec.AddIdentityFile(input.IdentityFile);
Console.Write("Connecting...");
exec.Connect();
Console.WriteLine("OK");
while (true)
{
string stdOut = null;
string stdError = null;
Console.Write("Enter a command to execute ['Enter' to cancel]: ");
string command = @"cd scr/bin/ && ./menu.sh";
if (command == "") break;
string output = exec.RunCommand(command);
Console.WriteLine(output);
}
Console.Write("Disconnecting...");
exec.Close();
Console.WriteLine("OK");
}
catch (Exception e)
{
Console.WriteLine(e.Message);
}