0

I would like to implement a version checking in a bash script, which would verify a file on my website, and then if the version of the script does not match the last version, it opens a web page. I heard I would use cURL, but didnt find any tuto about my case.

Djayb6
  • 1

1 Answers1

0

I'm just gonna write what I would do:

#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"
norcalli
  • 1,215
  • 2
  • 11
  • 22