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.