Install/Linux

cURL을 이용한 헤더 응답코드 활용 방법

Kim Bob 2019. 10. 8. 19:29

3초 타임아웃 기준 Header의 응답코드 기준 400 이상

#!/bin/bash

url="http://google.com"

read -ra result <<< $(curl -Is --connect-timeout 3 "${url}" || echo "timeout 500")
status=${result[1]}
if [ $status -ge 400 ]
then
    echo $status
fi