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

425
Views
Go up a directory to run a python script in parent directory, using Node Js Child Process

I am having issues figuring out how I can go up a directory from my server running to run a python script. I am able to run a python script using the child process, {spawn}, however, I am unable to go up once, to the parent directory to run the python script.

The code I currently have works only if the file is in the current direcrtory

    const b = brand+'.py'

    const childPython = spawn('python3', [b]);

    childPython.stdout.on('data', (data) =>{
        console.log(`data: ${data}`)
    })
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I presume you're using child_process.spawn() to run your python script. To go up one directory level from where your script is, you can just pass the cwd (current working directory) option to child_process.spawn().

child_process.spawn(command, args, {
    cwd: path.resolve(__dirname, "..")
});
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!