我正在尝试将 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)
我不明白为什么我会得到这个输出(不管命令如何),任何输入都将不胜感激。
谢谢, …
我在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)