在Powershell中,我如何将标准输出重定向到标准错误?Powershell将标准输出重定向到标准错误
我知道我可以做反过来与2>&1
所以我尝试:
echo "Hello" 1>&2
但我得到一个愚蠢的错误The '1>&2' operator is reserved for future use.
我问,因为能够做到这将使它更容易为我调试另一个问题。见$LastExitCode=0 but $?=False in PowerShell. Redirecting stderr to stdout gives NativeCommandError
您是否正在调用PowerShell写入标准输出的外部程序? –
是------------ –
那么,为什么不只是捕获它的输出,并把它当作写入标准错误呢? '$ output =&externalprog.exe 2>&1'。变量存储您想要发送到标准错误的输出。 –