2017-07-31 128 views
1

我通過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(這就是我要救什麼)。

回答

0

該命令可能打印其輸出到錯誤輸出流,而不是標準的輸出流。

要捕獲錯誤流,加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

相關問題