See the manual for StartProcess
. With a small adaptation to the example given there, you should be able to achieve the goal.
Just an example application
pathtoexe = "echo";
Opens a stream, which in Mathematica is called ProcessObject
process = StartProcess[pathtoexe]
Writes three lines to a standard input:
WriteLine[process, "write string one"];
WriteLine[process, "write string two"];
WriteLine[process, "write string three"];
Note, that each time WriteLine
by default already adds the "enter" as a hidden linefeed character \n
. Thus, if you just need an extra "enter" in the end, just send a empty string once more:
WriteLine[process, ""];
Close the process, if it already has not stopped:
KillProcess[process]
PleaseIf this does not solve your problem, then please extend your question with a more specific example. Then, such that we cancould run the same code as you and help you more efficiently.