问题
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