windows:是否可以将文本文件转储(直接)到命名管道中
我有一个程序获取输入的设置,如下所示:
1)用户在命令提示符中输入命令
2)命令提示符中的文本写入命名管道
3)管道另一侧的进程正在读取输入解析并执行命令
我希望能够在文本文件中存储一组命令,然后获得文本文件的命名管道提要。
有什么方法可以将管道和锉刀连接在一起吗?或者我是否需要读取文本文件并将其分成几行,然后将其一一写入管道
I have a setup where a program gets its input like so:
1) user enters a command in a command prompt
2) the text from the command prompt is written to a named pipe
3) a process on the other side of the pipe is reading the input parse and execute the command
I would like to have the ability to store a set of commands in a text file and then have the named pipe feed of the text file.
is there some way to chine the pipe and the file together? or do I need to read the text file and split it into lines which I will write to the pipe one by one
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果您使用命名管道,
如果您查看 这个,你可以看到他们使用普通的
CreateFile
来打开管道,看看那个,看来你不能重定向但你必须读写,至少与API是一样的ReadFile
WriteFile
。If you use named pipe it might be possible,
if you take a look at this, you can see they use plain
CreateFile
to open the pipe, taking a look at that, it seems you cannot redirect but you have to read and write, at least with the API is the sameReadFile
WriteFile
.您应该能够使用
TYPE
:尽管如果您明确需要命名管道,或者需要通过管道连接到已经运行的进程,则这将不起作用。
不过在这种情况下,您可以使用存根程序将其 STDIN 写入命名管道。
You should be able to use
TYPE
:Though this won't work if you explicitly require a named pipe, or need to pipe into an already-running process.
Though in that case, you could use a stub program which writes its STDIN to the named pipe.