Results 1 to 3 of 3

Thread: Why does wget output go to standard error?

  1. #1
    Join Date
    Sep 2013
    Beans
    1

    Why does wget output go to standard error?

    I recently discovered that wget's output goes to stderr instead of stdout. I've updated my scripts to take account for this, but it feels like bad design to me *however* I'm so new to Ubuntu I'm sure I must be missing something.

    Why was this design choice made?

    By reading the man page at http://www.gnu.org/software/wget/manual/wget.html it appears as though using stderr was a way to let you have document contents go to stdout if you so desired, but it just feels wrong. By design stderr should be used for error text. How many 'std*'s are there? Couldn't you just have an arbitrary number of them when designing your application, using custom file descriptor indexes for each one? So in the case of wget you could have a 'stddocument' which is actually &3 or &4 or whatever minimum unused file descriptor is available.

    Any discussion that helps illuminate this for me appreciated.

  2. #2
    Join Date
    Sep 2007
    Location
    Netherlands
    Beans
    454
    Distro
    Ubuntu 16.04 Xenial Xerus

    Re: Why does wget output go to standard error?

    AFAIK there are three std*'s stdin, stdout and stderr.

    I can only guess that choosing stderr for regular output was done so as not to interferen with the progress output which is directed to stdout I presume.

    If you are interested in redirecting the output, you needn't be aware as to where it redirects to normally. Just use the
    Code:
    -o logfile
    or
    Code:
    -a logfile
    command-line argument as per the documentation link you provided.
    Never upgrade your working system to the newest release without thorough testing on the actual hardware you will be running it on.
    Never perform a system update in a live session
    Installed Ubuntu Touch 1.0 on my Nexus 7. And loving it!

  3. #3
    Join Date
    Aug 2011
    Beans
    1

    Re: Why does wget output go to standard error?

    If you look at the man page for stderr (emphasis mine) it notes

    Under normal circumstances every UNIX program has three streams opened for it when it starts up, one for input, one for output, and one for printing diagnostic or error messages.

    If you look at the standard output written to the terminal by wget, you can see that is is all diagnostic information

    wget http://serverfault.com >1.out
    --2013-09-09 09:36:26-- http://serverfault.com/
    Resolving serverfault.com... 198.252.206.16
    Connecting to serverfault.com|198.252.206.16|:80... connected.
    HTTP request sent, awaiting response... 200 OK
    Length: 51374 (50K) [text/html]
    Saving to: “index.html”
    100%[================================================== ====================================>] 51,374 228K/s in 0.2s

    2013-09-09 09:36:27 (228 KB/s) - “index.html” saved [51374/51374]
    It appears that wget is using the standard streams as intended.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •