发送短信到Windows控制台应用程序的标准输入 [英] Send text to standard input of a Windows console app

查看:184
本文介绍了发送短信到Windows控制台应用程序的标准输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图写一个bat文件自动执行某些shell命令。大多数命令是简单,我可以把它们放进批处理文件直接,但有一个命令,它,而不是采取命令行参数,期待您键入您希望使用的标准输入选项。我不完全知道是什么意思。谁能告诉我如何做到这一点?我想输入的文字是在目录中的一个文件中的内容:我想用批处理文件$(additionaloptions)里面的变量来连接options.txt

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)".

请有意义吗?

推荐答案

通常的方式.bat文件要做到这一点是使用echo写一个小的文本文件,然后重定向文本文件,以标准的命令。

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.

@echo foo > bar.txt
@echo if you need multiple lines >> bar.txt

the_cmd < bar.txt

在特定示例中它会像

copy myfile.txt bar.txt
@echo %variable% >> bar.txt

这是你提到的$(变量)建议,我认为这是一个makefile,而不是一个批处理文件的事实。在Makefile,那里有一个更好的办法。

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.

这篇关于发送短信到Windows控制台应用程序的标准输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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