Get web pages and compare

Hello,

I'm writing a shell script to wget content web pages from multiple server into a variable and compare

if they match return 0 or return 2

#!/bin/bash

# Cluster 1
CLUSTER1_SERVERS="srv1 srv2 srv3 srv4"
CLUSTER1_APPLIS="test/version.html test2.version.jsp"

# Liste des clusters �  tester
CLUSTERS="CLUSTER 1"

# Liste des servers �  tester
SERVERS="CLUSTER1_SERVERS"

# init vars
CRITICAL=2
WARNING=1
OK=0


for applis in $CLUSTER1_APPLIS
do
        CONTENT=$(wget -q -O - "http://$SERVERS/$applis")
        if [ "$CONTENT" != 1 ]
        then
        exit_code=2
        else
        exit_code=0
        fi
done

case $exit_code in
        "2")
                echo "CRITICAL - App Version Mismatch"
                exit 2
                ;;
        "1")
                echo "WARNING"
                exit 1
                ;;
        "0")
                echo "OK - All apps have the save version"
                exit 0
                ;;
        *)
                echo "CRITICAL - there's something wrong with this script ..."
                exit 2
                ;;
esac

this script dosent seems to work, i think there is some pbr in the line (comparison)

 if [ "$CONTENT" != 1 ]

any help or suggestions

thanks in advance
gtam

what is the outcome expected from :

wget -q -O - "http://$SERVERS/$applis"

?

hello panyam

wget prints the content of the web pages in standard output

I am more intereseted in the output of the below command:

wget -q -O - "http://$SERVERS/$applis"

Does it returns just "0" or "1", since you are comparing the outcome of the command against "1".

no the wget does not return 0 or 1

hear is the sample output i get if i run this command on one of my web server

wget -q -O - "http://srv1/test/version.html

<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>version</title>
  </head>
  <body>
    <h1>test</h1>
    <h2>Version: 2.0.0</h2>
    <h2>Environnement : TEST</h2>
    <h2>Build Number: 20130114_1629</h2>
  </body>