Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

202
Vistas
NodeJS child_process send input

I have a python script as follows :

print ("hello world ")
x = input("Enter a number: ")
print(x)

Now I want to programitically run the same using the below NodeJS code:

var spawn = require("child_process").spawn;

child = spawn("python", ["./test.py"]);


child.stdout.on("data", (data) => {
  console.log(`${data}`);
  child.stdin.write("7\n");
});

But the output isn't as expected and is like below:

hello world 
Enter a number: 
7

Is there any way I can send input to the node child process once the script awaiting for input?

about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda