ssh를 사용하여 명령을 실행하고 싶습니다.
I이 예에서와 같이 SharpSSH library을 사용하고 있습니다 :SharpSSH로 출력을 생성하지 않는 명령 실행
using System;
using Tamir.SharpSsh;
class Program {
static void Main(string[] args) {
string hostName = "host.foo.com";
string userName = "user";
string privateKeyFile = @"C:\privatekey.private";
string privateKeyPassword = "xxx";
SshExec sshExec = new SshExec(hostName, userName);
sshExec.AddIdentityFile(privateKeyFile, privateKeyPassword);
sshExec.Connect();
string command = string.Join(" ", args);
Console.WriteLine("command = {0}", command);
string output = sshExec.RunCommand(command);
int code = sshExec.ChannelExec.getExitStatus();
sshExec.Close();
Console.WriteLine("code = {0}", code);
Console.WriteLine("output = {0}", output);
}
}
내 문제는 내가 실행 명령이 더 출력을 생성하지 않을 때, 내가 얻을 -1 리턴 코드로 대신의 명령에 의해 반환되는 코드입니다 원격 기계.
누군가이 문제가 발생 했습니까? 아니면 제가 잘못 했나요?
RunCommand에 과부하를 사용하고 stdOut 및 stdErr을 무시하고 종료 코드를 읽은 적이 있습니까? 차이가별로없는 것 같아요. – kamranicus