Windows batch script: Pipe text into a command line application

只谈情不闲聊 提交于 2021-01-28 02:23:14

问题


I'm writing a batch script to automate some 3D printing processes. Right now, my code looks like this:

echo connect COM5 230400>3dprint.txt
echo load 3dprint01.gcode>>3dprint.txt
echo print>>3dprint.txt
type 3dprint.txt | C:\Printrun\pronsole.exe

So Pronsole is a command-line application that takes user-inputted commands (like connect, load and print above). Above, I've made the batch file create a text file and pass that into the application - except when it hits the EOF, this causes pronsole to crash.

Is there an alternate way to pass (stdin style) text to this command line application that doesn't send an EOF?

NB. The text commands don't all need to be sent at once either, but I imagine piping each line would cause a new instance of pronsole.exe to be opened each time?


回答1:


This may suffer the same issue. Also try removing the terminal CR/LF in the txt file.

C:\Printrun\pronsole.exe <3dprint.txt



回答2:


There simply isn't an EOF at the end of 3dprint.txt AFAIAA.

I'd try appending a line with the exit command for pronsole.exe, whatever that is. EXIT maybe, or QUIT



来源:https://stackoverflow.com/questions/20768561/windows-batch-script-pipe-text-into-a-command-line-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!