2016-01-11 60 views
2

我正在使用Tmir.SharpSsh - SshExec方法为了发送一些命令到远程SSH服务器。Tamir.SharpSsh重定向输出(Sha1)

问题是,此方法或它创建的某个线程将输出发送到我的控制台窗口(“Sha1”)。

我想问问,如果有人知道我可以禁用此打印或将其重定向到一些临时文件。

public static bool OpenConnection (ConnectionInfo info) 
    { 
     string command = "nslookup " + info.IP + "| grep \"name = \" | awk -F\" = \" '{print $2}' | cut -d\".\" -f-1"; 
     exec = new SshExec(info.IP, info.UserName,info.Password); 

     try 
     { 

      exec.Connect(); 
      if (exec.Connected) 
      { 
       Console.WriteLine("Connection to {0} is successfully", info.IP); 
       info.Hostname=(exec.RunCommand(command)).Trim().ToUpper();//retrive Hostname from the RPA 
       return true; 
      } 

      else 
       return false; 

     } 
     catch (Exception ex) 
     { 
      Console.WriteLine(ex.Message); 
      return false; 
     } 

    } 

Console Output

回答

1

必须禁用行Console.WriteLine("Sha1");到名为public byte[] doFinal()的方法,该文件HMACSHA1.cs

+0

大感谢... – almog50