0

In bash, a named pipe can be kept open with cat > mypipe. How can this be done in python? This is what I have so far:

import subprocess
import os

if not os.path.exists("/tmp/mypipe"):
    os.mkfifo("/tmp/mypipe")
4

1 に答える 1

1
import os
import subprocess

path = '/tmp/mypipe'
if not os.path.exists(path):
    os.mkfifo(path)

with open(path, 'w') as f:
    subprocess.call(['cat'], stdout=f)
于 2013-06-12T09:27:26.960 に答える