[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: How to pipe just stderr to stdin in a pipeline?

From: Eli Schwartz
Subject: Re: How to pipe just stderr to stdin in a pipeline?
Date: Mon, 11 May 2020 17:53:58 -0400
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.7.0

On 5/11/20 5:25 PM, Peng Yu wrote:
> One use case is wget which needs to divert the real content from the
> response header, in which case the response header needs to be dump to
> stderr if tempfiles should be avoided. But then handing stderr will be
> important.

Why does stderr need to be "handled"? wget's diagnostics are important
to users to read and understand. Are you suggesting you are parsing them?

given wget by default does not serve downloaded files to stdout, but
saves them to specific files, I would venture to say you should probably
not be overriding this with -O -

If you really, really, really need to handle both the file contents and
information about the file, and they must be stored in bash variables
because you cannot stand the idea of using tempfiles for their intended
purpose, then you might be able to use curl, and create some custom data
format of your very own using the power of curl's -w / --write-out
'mydelimiter%{curl_variable}' to append arbitrary data to your stdout
stream, which you may then parse by going backwards through the contents
of your saved variable.

You should be doing this anyway, because curl -w is a lot more
script-friendly (and stable, it's *intended* to be parsed) than wget's
logging options.

Eli Schwartz
Arch Linux Bug Wrangler and Trusted User

Attachment: signature.asc
Description: OpenPGP digital signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]