2011-01-26 7 views
0

私のウェブサイト上のファイルを検証するbashスクリプトでバージョンチェックを実装したいのですが、スクリプトのバージョンが最後のバージョンと一致しない場合は、ウェブページ。私はcURLを使うと聞いていましたが、私の事件については何の言い方も見つけられませんでした。bashスクリプトでバージョンチェックを実装する

答えて

0

私よ、私はどうなるのか、単につもり書き込み:

#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" 
関連する問題