Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

102
Views
I want to use spawn from node js with python

I need to use a python3 script executed by js sever, i dont know how to set the variables like --name on spawn, thats my problem.

this is my code on js:


var { spawn } = require('child_process');

console.log("--------------------SART---------------------");
       
var path = "/home/usr/Documentos/Proyectos/Repos/test_recurrent.py";


pythonProcess = spawn('python3',[path]);


console.log("--------------------SPAWN---------------------");
pythonProcess.stdout.on('data', (data) => {
    console.log(`stdout: ${data}`);
  });
  
  pythonProcess.stderr.on('data', (data) => {
    console.error(`stderr: ${data}`);
  });
  
  pythonProcess.on('close', (code) => {
    console.log(`child process exited with code ${code}`);
  });

I need execute this line :


python3 test_recurrent.py --name "Default_name" --dataroot "/home/usr/UIInputs" --which_epoch 72000 --ancho_ventana 512 --alto_ventana 1200 --numero_imagenes 4 --numero_generaciones 7 --output_path "/home/usr/UIResults" --xcoor 1526 1526 1526 1526 --ycoor 3995 3995 3995 3995 

i have no idea about how to set this variables.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

you can pass switches as list after your path

var { spawn } = require('child_process');

console.log("--------------------SART---------------------");
       
var scriptPath = "/home/usr/Documentos/Proyectos/Repos/test_recurrent.py";

pythonProcess = spawn('python3', [scriptPath, "--name", "Default_name", "--dataroot", "/home/usr/UIInputs", "--which_epoch", "72000", "--ancho_ventana", "512", "--alto_ventana", "1200", "--numero_imagenes", "4", "--numero_generaciones", "7", "--output_path", "/home/usr/UIResults", "--xcoor", "1526 1526 1526 1526", "--ycoor", "3995 3995 3995 3995"]);

console.log("--------------------SPAWN---------------------");
pythonProcess.stdout.on('data', (data) => {
    console.log(`stdout: ${data}`);
  });
  
  pythonProcess.stderr.on('data', (data) => {
    console.error(`stderr: ${data}`);
  });
  
  pythonProcess.on('close', (code) => {
    console.log(`child process exited with code ${code}`);
  });
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!