Skip to main content
added 2 characters in body
Source Link
Johu
  • 5k
  • 17
  • 43

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.

See the manual for StartProcess. With a small adaptation 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]

Please extend your question with more specific example. Then we can run the same code as you and help you more efficiently.

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]

If this does not solve your problem, then please extend your question with a more specific example, such that we could run the same code as you and help you more efficiently.

Source Link
Johu
  • 5k
  • 17
  • 43

See the manual for StartProcess. With a small adaptation 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]

Please extend your question with more specific example. Then we can run the same code as you and help you more efficiently.