【发布时间】:2021-09-21 13:07:23
【问题描述】:
我想知道这个 Bash 命令是否可以转换为 PowerShell:
openssl s_client -showcerts -connect host:port </dev/null 2>/dev/null | openssl x509 -noout -dates
当前脚本(不工作):
.\openssl s_client -showcerts -connect host:port 2>$null | .\openssl x509 -noout -dates
缺少的</dev/null 使它无限等待输入。该语法是否有 PowerShell 替代方案?
<$null 不起作用,因为< 保留供将来使用。
有什么建议吗?
【问题讨论】:
-
我没有使用 powershell 的经验,但“普通”命令 shell 使用
NUL作为 bitbucket。你试过<NUL和 Powershell 吗? -
将一个空字符串通过管道传递给
openssl s_client:'' |.\openssl s_client ...。或者一个 NUL 字节:[char]0 |.\openssl s_client ... -
@MathiasR.Jessen,只有
@() | ...真正提供no 输入。
标签: powershell stdin exit