2011-01-26 4 views
0

bash 스크립트에서 내 웹 사이트의 파일을 확인하는 버전을 구현하고 싶습니다. 그런 다음 스크립트 버전이 마지막 버전과 일치하지 않으면 웹 페이지. 나는 cURL을 사용할 것이라고 들었지만 내 경우에 대해서는 어떤 tuto도 찾지 못했습니다.bash 스크립트로 버전 검사 구현하기

답변

0

I 해요 내가 어떻게 할 것인지 단지 거 쓰기 :

#configuration 
VERSION=1.0.0 
URL='http://example.com/version' 
DL_URL='http://example.com/download' 
#later on whenever you want 
# Assume the url only displays the current version number 
CHECK_VERSION=$(wget -O- "$URL") 
# If you remove the periods, it works as a way to 
# lexicorigraphically compare the version numbers as numbers 
CURRENT_NUMBER=$(echo "$VERSION" | tr -d '.') 
NEW_NUMBER=$(echo "$CHECK_VERSION" | tr -d '.') 
test "$CURRENT_NUMBER" -gt "$NEW_NUMBER" || x-www-browser "$DL_URL" 
관련 문제