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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:12:23+00:00 2026-05-28T07:12:23+00:00

I have some trouble with python. I am trying to get output from a

  • 0

I have some trouble with python. I am trying to get output from a running script and use it in another script. So, what I want to do is something like this;

Suppose the out.py and in.py like these;

# out.py
def main():
    while True:
        print "test"
        time.sleep(10)
main()

# in.py
text = sys.stdin.readline()
print "hello " + text

I want to run scripts like this,

$ python out.py | python in.py

but, this hangs and prints nothing instead printing “hello test” every 10 seconds. From this, I am guessing that | waits until the out.py terminates. All right then, what if I want to use in.py with a daemon?

My actual problem is; I’m trying to get output from arpwatch. arpwatch is running as daemon, and send ip/mac pairings to the stderr. I want to get that output and parse it; so, I need something like this;

$ arpwatch | python myscript.py

to achive this, how should i code myscript.py? I have tried to use subprocess module, but I had no success again. I hope I could clearly explain my problem since my English is decent.

Thanks for any help.

  • 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-28T07:12:24+00:00Added an answer on May 28, 2026 at 7:12 am

    The problem is one of buffering. It goes away if you explicitly flush stdout in out.py:

    import sys
    import time
    
    def main():
        while True:
            print "test"
            sys.stdout.flush()
            time.sleep(10)
    main()
    

    Unfortunately, you’ll have to rely on arpwatch doing this itself; if it doesn’t, you’ll want to try PTYs instead of pipes, since those count as terminals and will cause most applications to use line buffering instead of block buffering.

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

Sidebar

Related Questions

I have some trouble achieving adequate real-time performance from my application and wondering if
I'm have some trouble with the fulltext CONTAINS operator. Here's a quick script to
Good Morning, i have some Trouble with the Zend Framework and Zend_DB_Select, i want
We have several Python 2.6 applications running on Linux. Some of them are Pylons
I have written a small Python application where I use PyGame for displaying some
I have some trouble trying to split large files (say, around 10GB). The basic
I'm trying to substitute something in a string in python and am having some
Using Mongokit with Python. Having some trouble working out get the last n number
I have a trouble with using ctypes lib in my python script. Here is
I have a trouble with Scons.Variables. I want to use config files with custom

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.