将文本发送到 Windows 控制台应用程序的标准输入
我正在尝试编写一个 .bat 文件来自动执行一些 shell 命令。大多数命令都很简单,我可以直接将它们放入批处理文件中,但有一个命令不采用命令行参数,而是希望您使用“标准输入”输入所需的选项。我不太确定这意味着什么。有人可以告诉我该怎么做吗?我想要输入的文本是目录中文件之一的内容:“options.txt”,我想将其与批处理文件“$(additionaloptions)”中的变量连接。
有道理吗?
I am trying to write a .bat file to automate some shell commands. Most of the commands are easy and I can just put them into the batch file directly, but there is one command which instead of taking command line parameters, expects you to type in the options you want using "the standard input". I'm not exactly sure what that means. Can someone tell me how to do this? The text I would like to be entered is the contents of one of the files in the directory: "options.txt" which I want to concatenate with a variable inside the batch file "$(additionaloptions)".
Make sense?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 .bat 文件中执行此操作的常用方法是使用 echo 写入一个小文本文件,然后将该文本文件重定向到命令的标准输入。
在您的具体示例中,它会类似于
您提到 $(variable) 的事实,这表明我这是一个 makefile 而不是批处理文件。对于 makefile,有更好的方法。
The usual way to do this in .bat files is to use echo to write a small text file, then redirect the text file to standard in of the command.
In your specific example it would something like
The fact that you are mention $(variable) suggests to me that this is a makefile rather than a batch file. for a makefile, theres a better way.