简体   繁体   中英

using ssh.net im not able to getting output

I'm not getting any output after running script. Please someone help me why the output is showing empty.

I can see its connecting to server.

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 );
            }
        }
    }
}

You'll get the response with yourCommand.Result

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM