在Windows命令行上伪造标准输入 [英] Faking standard input on the Windows command line

查看:178
本文介绍了在Windows命令行上伪造标准输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用 Evernote的ENScript.exe 创建新笔记,输入文本和标题作为参数。问题是ENScript只允许通过文件或通过标准输入输入文本。



对于我目前的解决方法,我使用.bat文件写参数一个文件,然后调用ENScript与 / s 参数指向该文件读取它,但强制默认标题为临时文件的文件名(一个行为,我不因此我的问题是:在Windows命令行上是否有伪造标准输入的方法,这样我可以使用一个参数(从另一个程序传递来) )生成笔记文本?脚本的开头是

  ENScript.exe createNote / i%1 
解决方案

>您正在寻找一个管道操作,捕获一个命令的输出,并将其作为输入发送到下一个命令。这是大多数操作系统中的标准功能。



Windows CMD的管道符号是 |



您的脚本可以像下面这样简单:

  @echo%〜2 | @ ENScript.exe createNote / i%1 

如果您的脚本被称为MakeNote.bat,

  MakeNoteyour title这是您的注释文本


I want to use Evernote's ENScript.exe to create new notes, entering the text and title as arguments. The problem is that ENScript only allows the text to be entered via a file or via standard input.

For my current workaround I use a .bat file to write the argument to a file, then call ENScript with the /s argument pointing to the file to read it in, but that forces the default title to the temporary file's filename (a behavior I do not want).

So my question is: Is there a way to "fake" standard input on the Windows command line so that I can use an argument (passed from another program) to generate the note text? The beginnings of the script would be something like

ENScript.exe createNote /i %1

with the standard input following.

解决方案

You are looking for a pipe operation that captures the output of one command and sends it as input to the next. This is a standard capability in most operating systems.

The pipe symbol for Windows CMD is |

Your script could be as simple as:

@echo %~2|@ENScript.exe createNote /i %1

If your script is called MakeNote.bat, you would call it like

MakeNote "your title" "This is the text of your note"

这篇关于在Windows命令行上伪造标准输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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