Plink命令结果未保存到本地文本文件 [英] Plink command results not being saved to local text file

查看:61
本文介绍了Plink命令结果未保存到本地文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在通过PuTTY的Plink功能调用远程ssh-我可以连接并运行命令,但不能将Output存储到另一个文本文件中-我的脚本为:

I am calling a remote ssh through PuTTY's Plink functionality - I am able to connect and run my commands but not able to store Output into another text file - my script is as:

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

此处创建了 OutputRes.txt ,但它完全空白.结果显示在命令行中,但没有保存到 OutputRes.txt 中(这就是我要保存的内容).

Here OutputRes.txt is created, but it is completely blank. The result is shown on the command line, but not saved into OutputRes.txt (that's what I want to save on).

推荐答案

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

The command probably prints its output to an error output stream, not standard output stream.

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

To capture the error stream, add 2> redirection:

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

要将标准输出和错误输出都捕获到同一文件,请使用 2>& 1 :

To capture both standard and error outputs to the same file, use 2>&1:

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

请参见使用命令重定向运算符.

这篇关于Plink命令结果未保存到本地文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆