c# - 使用 ssh.net 我无法获得输出
问题描述
运行脚本后我没有得到任何输出。请有人帮助我为什么输出显示为空。
我可以看到它连接到服务器。
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 );
}
}
}
}
解决方案
你会得到回应yourCommand.Result
SshCommand command = client.CreateCommand("service --status-all");
command.Execute();
Console.WriteLine(command.Result)
推荐阅读
- javascript - 角度多个模块导入问题
- flutter - 如何显示在firebase中发布信息的用户
- apache-spark - 如何在 sklearn.cross_val_predict 中使用 spark
- python - 如何使用 pandas 为不同列聚合具有不同条件的数据?
- flutter - FutureBuilder 主体可能正常完成,导致返回“null”,但返回类型可能是不可为空的类型
- python - Python:将使用 open('file.ext', 'rb').read()[4000:4005] 将所有文件加载到内存中吗?
- python - 在python中创建一个列表
- javascript - OpenAI 不返回结果?
- python - 如何根据日期列合并两个数据框?
- javascript - 获取 https://localhost/fetch/doc.xml 404(未找到)