Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8207533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T09:01:39+00:00 2026-06-07T09:01:39+00:00

How do you specify what directory the python module subprocess uses to execute commands?

  • 0

How do you specify what directory the python module subprocess uses to execute commands? I want to run a C program and process it’s output in Python in near realtime.

I want to excute the command (this runs my makefile for my C program:

make run_pci

In:

/home/ecorbett/hello_world_pthread

I also want to process the output from the C program in Python. I’m new to Python so example code would be greatly appreciated!

Thanks,
Edward

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T09:01:42+00:00Added an answer on June 7, 2026 at 9:01 am

    Use the cwd argument to Popen, call, check_call or check_output. E.g.

    subprocess.check_output(["make", "run_pci"],
                            cwd="/home/ecorbett/hello_world_pthread")
    

    Edit: ok, now I understand what you mean by “near realtime”. Try

    p = subprocess.Popen(["make", "run_pci"],
                         stdout=subprocess.PIPE,
                         cwd="/home/ecorbett/hello_world_pthread")
    for ln in p.stdout:
        # do processing
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So, I want to run a Python program with a home-directory install of PyProj
Is there a way to specify the running directory of command in Python's subprocess.Popen()
I'm trying to specify a relative directory in the web.xml file. I basically want
Is there a way to specify the root directory at runtime within a program's
Suppose that I want to install a binary module for Python on Windows. Suppose
i would like to run a git pull and specify the directory. some say
When building a Delphi 2009 component package, how do you specify which directory should
I wonder if one can let the user specify an installation directory for an
Normally when linking against a static library, I have to specify a library directory
I have a super pom defined in which I specify a "resources" directory for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.