Testing if a server is up with curl and grep. Grep adds headings?

interstar asked:

Hi I’m trying to see if a server I’m running has been stopped (if it has, it returns a 502 Bad Gateway message.)

So I tried to do this :

curl http://MY_URL | grep "502"

The curl part returns what I expect it to.

But when I pipe it into grep, grep seems to be adding a bunch of headings :

  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
113   682  113   682    0     0   230k      0 --:--:-- --:--:-- --:--:--  666k

These aren’t in the output from curl. And grep on ordinary text files doesn’t add them. So why are they getting added to curl piped through grep?

My answer:

That output is from curl. It’s added when standard output is not a terminal, and in some other circumstances. Use curl -s if you don’t want to see it.

View the full question and answer on Server Fault.

Creative Commons License
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.