Making curl send errors to stderr and everything else to stdout

前端 未结 4 2060
迷失自我
迷失自我 2020-12-10 00:20

Is there a way to tell curl to output errors to stderr, and everything else to stdout?

The reason is that I am using curl from the command line (actually a cronjob)

4条回答
  •  温柔的废话
    2020-12-10 01:20

    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

提交回复
热议问题