簡體   English   中英

使用 ssh.net 我無法獲得 output

[英]using ssh.net im not able to getting output

運行腳本后我沒有得到任何 output 。 請有人幫助我為什么 output 顯示為空。

我可以看到它連接到服務器。

namespace WebApplication10.helpers
{
    public class service
    {
        public static List<Servicestatus> serviceadd(servername,UserName,Password)
        {
            List<Servicestatus> results = new List<Servicestatus>();
            try
            {
                using (var client = new SshClient(servername, UserName, Password))
                {
                    client.Connect();

                    SshCommand strOutput = client.CreateCommand("service --status-all");
                    var str = strOutput.Execute();

                    Console.WriteLine(str)

                    client.Disconnect();
                }
            }
            catch (Exception e)
            {
                Console.WriteLine( e.Message );
            }
        }
    }
}

您將通過yourCommand.Result獲得響應

SshCommand command = client.CreateCommand("service --status-all");
command.Execute();
Console.WriteLine(command.Result)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM