【问题标题】:Plink command results not being saved to local text filePlink 命令结果未保存到本地文本文件
【发布时间】:2017-07-31 11:08:45
【问题描述】:

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

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

这里创建了OutputRes.txt,但它完全是空白的。结果显示在命令行上,但没有保存到OutputRes.txt(这是我要保存的)。

【问题讨论】:

    标签: cmd putty plink


    【解决方案1】:

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

    要捕获错误流,请添加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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-07-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-16
      相关资源
      最近更新 更多