【问题标题】:Tamir.SharpSsh Redirect Output (Sha1)Tamir.SharpSsh 重定向输出 (Sha1)
【发布时间】:2016-04-15 18:48:08
【问题描述】:

我正在使用 Tmir.SharpSsh - SshExec 方法来向远程 SSH 服务器发送一些命令。

问题是这个方法或它创建的某个线程将输出发送到我的控制台窗口(“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; 
        }

    }

【问题讨论】:

    标签: c# output console-application


    【解决方案1】:

    您必须在文件HMACSHA1.cs 中名为public byte[] doFinal() 的方法中禁用Console.WriteLine("Sha1");

    【讨论】:

      猜你喜欢
      • 2011-06-04
      • 2014-03-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-04-30
      • 1970-01-01
      相关资源
      最近更新 更多