当前位置: 首页>>代码示例>>C#>>正文


C# SshClient.RunCommand方法代码示例

本文整理汇总了C#中SshClient.RunCommand方法的典型用法代码示例。如果您正苦于以下问题:C# SshClient.RunCommand方法的具体用法?C# SshClient.RunCommand怎么用?C# SshClient.RunCommand使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SshClient的用法示例。


在下文中一共展示了SshClient.RunCommand方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RebootButton_Click

 protected void RebootButton_Click(object sender, EventArgs e)
 {
     try
     {
         using (var client = new SshClient("ra-jetson.duckdns.org", "ubuntu", "savingL1v3s"))
         {
             client.Connect();
             client.RunCommand("sudo /home/ubuntu/Desktop/bandhan/SQL-Scripts/./RightAlertRemoteRebootIssued-SQL"); // SSH Command Here
             client.RunCommand("sudo reboot"); // SSH Command Here
             client.Disconnect();
         }
     }
     catch (Exception ex)
     {
         Response.Redirect("Down.html");
     }
 }
开发者ID:sbobhate,项目名称:Right-Alert,代码行数:17,代码来源:Users.aspx.cs

示例2: CleanCurrentFolder

 public void CleanCurrentFolder()
 {
     using (var client = new SshClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
     {
         client.Connect();
         client.RunCommand("rm -rf *");
         client.Disconnect();
     }
 }
开发者ID:nahidupa,项目名称:localtunnel-net-client,代码行数:9,代码来源:CreateDirectoryTest.cs

示例3: Test_Run_SingleCommand

        public void Test_Run_SingleCommand()
        {
            var host = Resources.HOST;
            var username = Resources.USERNAME;
            var password = Resources.PASSWORD;

            using (var client = new SshClient(host, username, password))
            {
                #region Example SshCommand RunCommand Result
                client.Connect();

                var testValue = Guid.NewGuid().ToString();
                var command = client.RunCommand(string.Format("echo {0}", testValue));
                var result = command.Result;
                result = result.Substring(0, result.Length - 1);    //  Remove \n character returned by command

                client.Disconnect();
                #endregion

                Assert.IsTrue(result.Equals(testValue));
            }
        }
开发者ID:delfinof,项目名称:ssh.net,代码行数:22,代码来源:SshCommandTest.cs

示例4: RemoveAllFiles

 private static void RemoveAllFiles()
 {
     using (var client = new SshClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
     {
         client.Connect();
         client.RunCommand("rm -rf *");
         client.Disconnect();
     }
 }
开发者ID:REALTOBIZ,项目名称:SSH.NET,代码行数:9,代码来源:ScpClientTest.cs

示例5: Test_Execute_Command_ExitStatus

        public void Test_Execute_Command_ExitStatus()
        {
            using (var client = new SshClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
            {
                client.Connect();

                var cmd = client.RunCommand("exit 128");
                Assert.IsTrue(cmd.ExitStatus == 128);

                client.Disconnect();
            }
        }
开发者ID:nahidupa,项目名称:localtunnel-net-client,代码行数:12,代码来源:TestSshCommand.cs

示例6: Test_Execute_Command_ExitStatus

        public void Test_Execute_Command_ExitStatus()
        {
            using (var client = new SshClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
            {
                #region Example SshCommand RunCommand ExitStatus
                client.Connect();

                var cmd = client.RunCommand("exit 128");
                
                Console.WriteLine(cmd.ExitStatus);

                client.Disconnect();
                #endregion

                Assert.IsTrue(cmd.ExitStatus == 128);
            }
        }
开发者ID:delfinof,项目名称:ssh.net,代码行数:17,代码来源:SshCommandTest.cs

示例7: Test_Ssh_Connect_Via_HttpProxy

        public void Test_Ssh_Connect_Via_HttpProxy()
        {
            var connInfo = new PasswordConnectionInfo(Resources.HOST, Resources.USERNAME, Resources.PASSWORD, ProxyTypes.Http, Resources.PROXY_HOST, int.Parse(Resources.PROXY_PORT));
            using (var client = new SshClient(connInfo))
            {
                client.Connect();

                var ret = client.RunCommand("ls -la");

                client.Disconnect();
            }
        }
开发者ID:delfinof,项目名称:ssh.net,代码行数:12,代码来源:PasswordConnectionInfoTest.cs

示例8: RunCommandTest

 public void RunCommandTest()
 {
     ConnectionInfo connectionInfo = null; // TODO: Initialize to an appropriate value
     SshClient target = new SshClient(connectionInfo); // TODO: Initialize to an appropriate value
     string commandText = string.Empty; // TODO: Initialize to an appropriate value
     SshCommand expected = null; // TODO: Initialize to an appropriate value
     SshCommand actual;
     actual = target.RunCommand(commandText);
     Assert.AreEqual(expected, actual);
     Assert.Inconclusive("Verify the correctness of this test method.");
 }
开发者ID:pecegit,项目名称:sshnet,代码行数:11,代码来源:SshClientTest.cs

示例9: OnInit

        protected override void OnInit()
        {
            base.OnInit();

            using (var client = new SshClient(Resources.HOST, Resources.USERNAME, Resources.PASSWORD))
            {
                client.Connect();
                client.RunCommand("rm -rf *");
                client.Disconnect();
            }
        }
开发者ID:pecegit,项目名称:sshnet,代码行数:11,代码来源:ScpClientTest.cs

示例10: RunCommand_CommandText_NeverConnected

 public void RunCommand_CommandText_NeverConnected()
 {
     using (var client = new SshClient(Resources.HOST, Resources.USERNAME, "invalid password"))
     {
         try
         {
             client.RunCommand("ls");
             Assert.Fail();
         }
         catch (SshConnectionException ex)
         {
             Assert.IsNull(ex.InnerException);
             Assert.AreEqual("Client not connected.", ex.Message);
         }
     }
 }
开发者ID:delfinof,项目名称:ssh.net,代码行数:16,代码来源:SshClientTest.cs


注:本文中的SshClient.RunCommand方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。