Plink命令结果未保存到本地文本文件

问题描述:

我通过PuTTY的Plink功能调用远程SSH - 我能够连接并运行我的命令,但无法将输出存储到另一个文本文件中 - 我的脚本如下:Plink命令结果未保存到本地文本文件

plink ssh_hostname -m "directory\till\inputCommand.txt" -l username -pw password > "directory\where\OutputTxt_Will_Be_Saved\OutputRes.txt" 

这里OutputRes.txt被创建,但它是完全空白的。结果显示在命令行上,而不是保存到OutputRes.txt(这就是我要救什么)。

该命令可能打印其输出到错误输出流,而不是标准的输出流。

要捕获错误流,加2>重定向:

plink ... 2> "directory\where\OutputTxt_Will_Be_Saved\ErrorRes.txt" 

同时捕获标准和错误输出到同一个文件,使用2>&1

plink ... > "directory\where\OutputTxt_Will_Be_Saved\OutputRes.txt" 2>&1 

Using command redirection operators

+0

我一直在寻找的答案...谢谢 – harveySp