예제 #1
0
            public async Task <SshCommandResult> Run(string commandText)
            {
                System.Console.WriteLine($"[SSH] Executing: {commandText}");
                var command = sshClient.CreateCommand(commandText);
                await Task.Factory.FromAsync(command.BeginExecute, command.EndExecute, null).ConfigureAwait(false);

                return(new SshCommandResult(command.ExitStatus, command.Result, command.Error));
            }
예제 #2
0
        public ListResult GetListResult()
        {
            var host = Host;
            var username = Username;
            var password = Password;
            using (var sshClient = new Renci.SshNet.SshClient(host, username, password))
            {
                sshClient.Connect();
                var cmd = sshClient.CreateCommand("tdtool --list", Encoding.UTF8);
                var commandResult = cmd.Execute();

                var listDeserializer = new ListDeserializer(new SensorListDeserializer());

                var result = listDeserializer.Deserialize(commandResult);

                return result;
            }
        }
예제 #3
0
 public static void AdoptDevice(string IP, string ControllerURL = "http://unifi.scharsich.dev:8080/inform")
 {
     using (var client = new Renci.SshNet.SshClient(IP, "ubnt", "ubnt"))
     {
         client.Connect();
         var cmd = client.CreateCommand("mca-cli-op set-inform " + ControllerURL);
         cmd.Execute();
         if (cmd.ExitStatus != 0)
         {
             MessageBox.Show(cmd.Error);
         }
         else
         {
             MessageBox.Show("Device " + IP + " adopted.");
         }
         client.Disconnect();
     }
 }