小编Jak*_*man的帖子

C# SSH 连接

我正在尝试将 SSH 命令作为 C# 应用程序的一部分运行。我的代码如下:

using System;
using Renci.SshNet;

namespace SSHconsole
{
    class MainClass
    {

        public static void Main (string[] args)
        {
            //Connection information
            string user = "sshuser";
            string pass = "********";
            string host = "127.0.0.1";

            //Set up the SSH connection
            using (var client = new SshClient (host, user, pass))
            {

                //Start the connection
                client.Connect ();
                var output = client.RunCommand ("echo test");
                client.Disconnect();
                Console.WriteLine (output.ToString());
            }

         }
    }
}
Run Code Online (Sandbox Code Playgroud)

根据我对 SSH.NET 的了解,这应该输出我认为应该是“test”的命令的结果。但是,当我运行程序时,得到的输出是:

Renci.SshNet.SshCommand

Press any key to continue...
Run Code Online (Sandbox Code Playgroud)

我不明白为什么我会得到这个输出(不管命令如何),任何输入都将不胜感激。

谢谢, …

c# ssh mono monodevelop ssh.net

3
推荐指数
1
解决办法
1万
查看次数

使用Python检查变量是否介于两个值之间

我在Python 3中计算一个人的BMI,需要检查BMI是否介于两个值之间.

这是我的代码:

def metricBMI():

    text = str('placeholder')

    #Get height and weight values 
    height = float(input('Please enter your height in meters: '))
    weight = float(input('Please enter your weight in kilograms: '))

    #Square the height value
    heightSquared = (height * height)

    #Calculate BMI
    bmi = weight / heightSquared

    #Print BMI value
    print ('Your BMI value is ' + str(bmi))

    if bmi < 18:
        text = 'Underweight'

    elif 24 >= bmi and bmi >= 18:
        text = 'Ideal'

    elif 29 >= bmi …
Run Code Online (Sandbox Code Playgroud)

python

0
推荐指数
1
解决办法
9083
查看次数

标签 统计

c# ×1

mono ×1

monodevelop ×1

python ×1

ssh ×1

ssh.net ×1