Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
620hun83707y@edwrodrig I'll have another look. I tried like 10 ways that were mentioned there, but they didn't work.
-
620hun83707y@-eth I have a chain that looks like this scanner command => converter => >stdout of Python <
I have trouble with the last part. I want to output to stdout, which would be read by PHP. -
afreitas2547ysys.stdout is a file-like object. You should be able to write whatever you want to it, including binary data. Also sys.stdout.flush() is a useful function
-
620hun83707yI GOT IT!
pipeline = subprocess.Popen(temp_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
pipeline.stdout.close()
pipeline.communicate()
It was the communicate() that did the trick.
Does anyone by any chance know how to pipe binary data out of Python? I digged through the first 10 pages of Google, but none of that did what I needed. I know how to pipe things between subprocesses, but not to the stdout of Python.
undefined