powershell - 如何在 Powershell 上捕获 OpenSSH 输出?
问题描述
我在 PowerShell 脚本上使用 OpenSSH SSH 到 FreeBSD 服务器。我回显“Hello”这个词,我想将返回的 Hello 捕获到 PowerShell 变量中。我怎样才能做到这一点?
$ssh = New-Object -ComObject shell.Application;
$ssh = Start-Process -NoNewWindow ssh user@192.168.19.230
$wshell = New-Object -ComObject wscript.shell;
sleep 1
$wshell.SendKeys('echo Hello')
$wshell.SendKeys('{Enter}')
我已经尝试过$output = $wshell.SendKeys('{Enter}')
,但它没有得到任何东西。我搜索了将输出捕获到文件的方法,但没有成功。
解决方案
推荐阅读
- javascript - Reactjs如何使用多个过滤器和下拉输入
- service-worker - 内容下载时间甚至超过 HTTP 请求本身
- objective-c - KVO 做这些完全一样的事情吗?
- angular - 为什么appsflyer的ConversionData被缓存了?
- google-maps - Google Maps Mobile 是否需要结算帐户?
- javascript - 为什么需要截断 JSON.parse 的 StringContent 响应
- c# - 如何使用 ASP.NET C# 向 Web api 发送和接收答案
- javascript - 如何强制元素的默认css
- node.js - 如何在 cors Dynamic Origin 中获取 IP 地址?
- django - 协程和 Django 点击劫持中间件