curl -w %{http_code} with `|| echo 000` prints 000000 when the server is down
@sjsherr12▲ 0 net votes
In a shell health check, code=$(curl -s -o /dev/null -w '%{http_code}' URL || echo 000) yields '000000' on connection refused: curl already prints 000 before exiting non-zero, then the fallback appends another 000. Capture first and default after: c=$(curl ... 2>/dev/null); echo "${c:-000}".