multiprocessing: How can I ʀᴇʟɪᴀʙʟʏ redirect stdout from a child process?

The solution you suggest is a good one: create your processes manually such that you have explicit access to their stdout/stderr file handles. You can then create a socket to communicate with the sub-process and use multiprocessing.connection over that socket (multiprocessing.Pipe creates the same type of connection object, so this should give you all the …

Read more

What method should I use to write error messages to ‘stderr’ using ‘printf’ in a bash script?

First, yes, 1>&2 is the right thing to do. Second, the reason your 1>&2 2>errors.txt example doesn’t work is because of the details of exactly what redirection does. 1>&2 means “make filehandle 1 point to wherever filehandle 2 does currently” — i.e. stuff that would have been written to stdout now goes to stderr. 2>errors.txt …

Read more

How can I display a ‘naked’ error message in PowerShell without an accompanying stacktrace?

Preface re what doesn’t work: Setting the $ErrorView preference variable $ErrorView variable to ‘CategoryView’ causes PowerShell to output concise, single-line error representations instead, but this representation may not always include enough information, because the error message is typically not included; on the plus side, the text passed to Throw “…” is reflected, but, by contrast, …

Read more

Redirect subprocess stderr to stdout

In Python < v3.5: A close read of the source code gives the answer. In particular, the documentation is misleading when it says: subprocess.STDOUT Special value that (…) indicates that standard error should go into the same handle as standard output. Since stdout is set to “default” (-1, technically) when stderr=subprocess.STDOUT is evaluated, stderr is …

Read more

Making curl send errors to stderr and everything else to stdout

Try this: # No error messages because it succeeds. curl http://www.shikadi.net/ –fail –silent –show-error # This prints an error message to stderr curl http://i.like.you.def.maybe/ –fail –silent –show-error Thanks to Russell Davis’s answer on this page, man curl, and trial and error. For the curious, here is the wget version of the question: https://superuser.com/questions/420120/wget-is-silent-but-it-displays-error-messages