Shell Script로 특정 URL의 상태를 체크하고자 합니다.
curl을 이용하면 간단 하네요.
curl은 결과를 exit code로 리턴 합니다.
exit codes list는 아래 man page를 참고하세요.
( http://curl.haxx.se/docs/manpage.html )
#! /usr/bin/sh
function check {
if [ $? -ne 0 ] ; then
echo "Error occurred getting URL $1:"
if [ $? -eq 6 ]; then
echo "Unable to resolve host"
fi
if [$? -eq 7 ]; then
echo "Unable to connect to host"
fi
exit 1
fi
}
curl -s -o "/dev/null" $1
check;
[ 출처 ]
반응형
'Dev > 기타' 카테고리의 다른 글
| 최적의 makrdown editor는 sublime text (0) | 2015.01.12 |
|---|---|
| 문자열 치환 (0) | 2014.09.25 |
| shell script로 구현하는 multi tail (0) | 2013.08.06 |
| 솔라리스 메일 전체 삭제 (0) | 2013.03.07 |
| CVS Commit 로그를 남겨보자 (4) | 2011.05.04 |