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 3351790
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T01:57:04+00:00 2026-05-18T01:57:04+00:00

I have to make two programs (for example a script A (.py) and script

  • 0

I have to make two programs (for example a “script A” (.py) and “script B”(.exe)) communicate.
Both programs are on a infinite loop: Script A needs to write to the stdin of script B and afterwards read the stdout of script B thereafter write again etc. Script B I cannot change.

Both files are on my hard disk, so I there must be a better way to solve this than networking. I can, however, write files with script A.
This is not course homework, I am writing a GUI for a game and I have a few AI’s preprogrammed.
I have thought of piping (python scripta.py | scriptb.exe), but that seemed to require script A to finish before script B could execute. Then again, as I’ve never used piping, I might have missed something obvious.

I would prefer if the tools needed would be part of standard library, but if they’re not, too bad.

The solution would have to work on both Linux and Windows.
Could any of you point me in the right direction?
Thank you for your time.

  • 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-05-18T01:57:05+00:00Added an answer on May 18, 2026 at 1:57 am

    If you start “Script B” from within “script A” using the subprocess module, you will be able to directly interact with its stdin and stdout. For example:

    from subprocess import Popen, PIPE
    
    prog = Popen("scriptA.exe", shell=True, stdin=PIPE, stdout=PIPE)
    
    prog.stdin.write("This will go to script A\n")
    print prog.stdout.read()
    
    prog.wait() # Wait for scriptA to finish
    

    Just be careful, as calls to read will block, meaning if the script doesn’t have anything to print, the call will hang until it does. The easiest way to avoid this is to use threading.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For example if I have an Enum with two cases, does it make take
I have two questions: 1) How can I make an array which points to
I have a two-dimensional array (of Strings) which make up my data table (of
I have two DateTime objects: StartDate and EndDate . I want to make sure
I have to make column charts in Excel using VBA only (no user input).
I have to make a schema for an XML format that's already being used.
I have a control which I have to make large modifications to. I'd like
For my university assignment I have to make a networkable version of pacman. I
In our application we sometimes have to make minor GUI modifications for different customers:
I'm working on an application where users have to make a call and type

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.