How to run an external program?

Hello.
How do I start a child program, for example java - "java-jar p.jar" and to the event of AMI output, and it is possible to enter your data input to transmitted directly into the child process.
How is this implemented? It can be an example with the event AMI?

Worked with node, there is implemented using child_process.spawn, my example with node:
const 
 { spawn } = require('child_process'),
 readline = require('readline'),
 rl = readline.createInterface({
 input: process.stdin,
 output: process.stdout
}),
 log = (str) => {
 process.stdout.write(`LOG: ${str}`)
}
 srv = spawn('sms.bat', { stdio: [null, null, process.stderr] });

rl.on('line', (input) => {
srv.stdin.write(`${input}\n`);
log(input);
});

srv.stdout.on('data', (data) => log(data.toString()));

srv.on('close', () => process.exit());

In py found subprocess, but how to do with the event AMI did not understand.

Thank you.
March 23rd 20 at 19:17
1 answer
March 23rd 20 at 19:19
I said to you! Take asyncio. And don't duplicate questions. And in Python there is no event in the understanding of nodejs. But there is async await. Until I deal with asynchronous programming in Python and asynchronous libraries, meaning something will not.
Sorry, that question was removed, I didn't see Your reply - Axel_Kli commented on March 23rd 20 at 19:22
@Axel_Kli, well, in the asyncio module is the module subprocess. This is a different, asynchronous subprocess. - toby.Jerde commented on March 23rd 20 at 19:25
@Axel_Kli, https://docs.python.org/3/library/asyncio-subproce... - toby.Jerde commented on March 23rd 20 at 19:28

Find more questions by tags Python