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

221
Vistas
Node.js spawn is not running python command

I am trying to run a python command from Node.js v12.22.1 in a web application. This is the method that is being called in one of my controllers:

async start ({request,response,params}) {
                Log.create(request.request.headers.user,request.url())
                const { spawn } = require('child_process');
                const command = spawn('python',[process.env.BUS_PATH+'inventario/SystemDManager.py', params.name, "start"]);

                var responseData = "teste";
                command.stdout.setEncoding('utf-8');
                command.stdout.on('data', function (data){
                        responseData += data.toString();
                });
                command.stderr.on('data', function (data){
                        responseData += data.toString();
                });
                command.stdout.on('end',function(data){
                        console.log(responseData);
                });

                return responseData
        }

Variables are correctly instantiated, I have already printed them:

process.env.BUS_PATH = /home/ubuntu/

params.name = witty

So that the request command is:

python /home/ubuntu/inventario/SystemDManager.py witty start

This command runs perfectly when I type it directly into the shell console. However, nothing happens when running it through spawn. Moreover, when I change spawn arguments to:

spawn('cp',[process.env.BUS_PATH+'inventario/SystemDManager.py', "dummy.txt"]);

It works fine, it makes the file copy ... Note that my responseData variable ends with "teste", as if nothing had happened. I have even tried to change "python" to "/usr/bin/python", but everything remains the same.

Does anyone has a tip of what is going wrong that python command is no being executed?

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