← Back to context

Comment by nothrabannosir

12 hours ago

The aws cli has a set of porcelain for s3 access (aws s3) and plumbing commands for lower level access to advanced controls (aws s3api). The plumbing command aws s3api get-object doesn't support stdout natively, so if you need it and want to use it in a pipeline (e.g. pv), you would naively do something like

  $ aws s3api get-object --bucket foo --key bar /dev/stdout | pv ...

Unfortunately, aws s3api already prints the API response to stdout, and error messages to stderr, so if you do the above you'll clobber your pipeline with noise, and using /dev/stderr has the same effect on error.

You can, though, do the following:

  $ aws s3api get-object --bucket foo --key bar /dev/fd/3 3>&1 >/dev/null | pv ...

This will pipe only the object contents to stdout, and the API response to /dev/null.

Would be nice if `curl` had something to dump headers to a third file descriptor while outputting the response on stdout.

  • This should work?

      curl --dump-header /dev/fd/xxx https://google.com
    

    or

      mkfifo headers.out
      curl --dump-header headers.out https://google.com
    

    unless I'm misunderstanding you.