Dealing with stdout / stderr is bash is just syntax. I don’t always remember it
off the top of my head but … stackoverflow.com.
On Linux at least it’s possible to pipe to arbitrary streams, it seems. The
following uses bash to write “Hi” to the file “third” opened by Python. I
determined the file was 5 empirically.
import os
import subprocess
command= 'echo Hi >/dev/fd/5'
fd = os.open("third",os.O_WRONLY|os.O_CREAT)
os.set_inheritable(fd,True)
subprocess.run(('/usr/bin/bash','-c',command),close_fds=False)
From: Python-list <[email protected]> on
behalf of Michael Torrie <[email protected]>
Date: Tuesday, January 3, 2023 at 5:18 PM
To: [email protected] <[email protected]>
Subject: Re: What should go to stdout/stderr and why Python logging write
everything to stderr?
*** Attention: This is an external email. Use caution responding, opening
attachments or clicking on links. ***
Maybe some day an interface and shell syntax will be developed to
interact with an arbitrary number of standard streams. Current piping
syntax really only works well with one stream and even trying to use
stderr and stdout with pipes and filters in a shell is awkward.
--
https://urldefense.com/v3/__https://mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!j8qV9yx1DJI_G2F-q1fQz2LfnVYoMi40Qpk_h8bxrOcw50rVXpwScpFJSyZ212Tm9rj6T7vKgJjaIEgLRw$<https://urldefense.com/v3/__https:/mail.python.org/mailman/listinfo/python-list__;!!Cn_UX_p3!j8qV9yx1DJI_G2F-q1fQz2LfnVYoMi40Qpk_h8bxrOcw50rVXpwScpFJSyZ212Tm9rj6T7vKgJjaIEgLRw$>
--
https://mail.python.org/mailman/listinfo/python-list