Sponsored Content
Full Discussion: Get web pages and compare
Top Forums Shell Programming and Scripting Get web pages and compare Post 302775583 by gtam on Tuesday 5th of March 2013 06:17:33 AM
Old 03-05-2013
Get web pages and compare

Hello

I'm writing a script to get content of web pages on different machines and compare them using their md5 hash

hear is my code


#!/bin/bash

# Cluster 1
CLUSTER1_SERVERS="srv01:7051 srv02:7052 srv03:7053 srv04:7054"
CLUSTER1_APPLIS="test/version.html test2/version.html test3/version.jsp test4/version.html test5/version.jsp"

# Cluster 2
CLUSTER2_SERVERS="srv01:7055 srv02:7056 srv03:7057 srv04:7058"
CLUSTER2_APPLIS="test/version.html test2/version.html test3/version.jsp test4/version.html"

# Cluster 4
CLUSTER4_SERVERS="srv01:7063 srv02:7064 srv03:7065 srv04:7066"
CLUSTER4_APPLIS="test/version.html test2/version.html"

# Liste des clusters ?* tester
CLUSTERS="CLUSTER1 CLUSTER2 CLUSTER4"

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

for cluster in $CLUSTERS
do
for server in $(eval echo \$${cluster}_SERVERS)
do
server_name=`echo $server | cut -d':' -f1,1`
server_port=`echo $server | cut -d':' -f2,2`
for applis in $(eval echo \$${cluster}_APPLIS)
do
checksum=`curl --silent --write-out '%{http_code}\n' "http://$server_name:$server_port/$applis" | md5sum`
if [[ ( "$checksum" -ne "$checksum1" ) ]]
then
exit_code=2
else
exit_code=0
fi
done
done
done

case $exit_code in
"2")
echo "CRITICAL - App Version Mismatch"
exit $CRITICAL
;;
"0")
echo "OK - All apps deployed are identical"
exit $OK
;;
*)
echo "CRITICAL - there's something wrong with this script ..."
exit $CRITICAL
;;
esac


getting web pages content and generation md5 hash works perfectly

but I'm a blocked when comparing them


if [[ ( "$checksum" -ne "$checksum" ) ]]


can someone guide me how i could accomplish this

thanks in advance
gtam
 

9 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Dynamic web pages for Unix Web Server

Hi, my company is considering a new development of our web site, which used to run on Apachi over Solaris. The company who is going to do this for us knows only about developing it in ASP. I guess this means we'll have to have another ISS server on NT for these dynamic pages :( What are... (5 Replies)
Discussion started by: me2unix
5 Replies

2. Shell Programming and Scripting

Count links in all of my web pages

Counts the number of hyperlinks in all web pages in the current directory and all of its sub-directories. Count in all files of type "*htm" and "*html" . i want the output to look something like this: Total number of web pages: (number) Total number of links: (number) Average number of links... (1 Reply)
Discussion started by: phillip
1 Replies

3. UNIX for Dummies Questions & Answers

Selecting information from several web pages...

Hi All! Is this possible? I know of several hundreds of urls linking to similar looking hp-ux man pages, like these. In these urls only the last words separated by / are changing in numbering, so we can generate these... http://docs.hp.com/hpux/onlinedocs/B3921-90010/00/00/31-con.html... (2 Replies)
Discussion started by: Vishnu
2 Replies

4. UNIX for Dummies Questions & Answers

Browse Web pages through command line

Is there any way to browse web pages while on the command line? I know wget can download pages, but I was wondering if there was an option other than that. (2 Replies)
Discussion started by: vroomlicious
2 Replies

5. Shell Programming and Scripting

Investigating web pages in awk

hello. i want to make an awk script to search an html file and output all the links (e.g .html, .htm, .jpg, .doc, .pdf, etc..) inside it. also, i want the links that will be output to be split into 3 groups (separated by an empty line), the first group with links to other webpages (.html .htm etc),... (1 Reply)
Discussion started by: adpe
1 Replies

6. UNIX for Dummies Questions & Answers

curl command with web pages

I can't quite seem to understand what the curl command does with a web address. I tried this: curl O'Reilly Media: Tech Books, Conferences, Courses, News but I just got the first few lines of a web page, and it's nowhere on my machine. Can someone elaborate? (2 Replies)
Discussion started by: Straitsfan
2 Replies

7. UNIX for Dummies Questions & Answers

Forcing web pages to anti-aliase

Here is an observation that has started to riddle me and perhaps someone can enlighten me. When a web page (or desktop page for that matter) uses the standard font, it is not anti-aliased, unless the user opts in to do so via the desktop settings. It appears however that fonts are not... (0 Replies)
Discussion started by: figaro
0 Replies

8. Shell Programming and Scripting

Checking Web Pages?

Hey guys, Unfortunatley, I can not use wget on our systems.... I am looking for another way for a UNIX script to test web pages and let me know if they are up or down for some of our application. Has anyone saw this before? Thanks, Ryan (2 Replies)
Discussion started by: rwcolb90
2 Replies

9. Shell Programming and Scripting

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... (4 Replies)
Discussion started by: gtam
4 Replies
ECHO(1)                                                            User Commands                                                           ECHO(1)

NAME
echo - display a line of text SYNOPSIS
echo [SHORT-OPTION]... [STRING]... echo LONG-OPTION DESCRIPTION
Echo the STRING(s) to standard output. -n do not output the trailing newline -e enable interpretation of backslash escapes -E disable interpretation of backslash escapes (default) --help display this help and exit --version output version information and exit If -e is in effect, the following sequences are recognized: \ backslash a alert (BEL)  backspace c produce no further output e escape f form feed new line carriage return horizontal tab v vertical tab NNN byte with octal value NNN (1 to 3 digits) xHH byte with hexadecimal value HH (1 to 2 digits) NOTE: your shell may have its own version of echo, which usually supersedes the version described here. Please refer to your shell's docu- mentation for details about the options it supports. AUTHOR
Written by Brian Fox and Chet Ramey. REPORTING BUGS
GNU coreutils online help: <http://www.gnu.org/software/coreutils/> Report echo translation bugs to <http://translationproject.org/team/> COPYRIGHT
Copyright (C) 2017 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>. This is free software: you are free to change and redistribute it. There is NO WARRANTY, to the extent permitted by law. SEE ALSO
Full documentation at: <http://www.gnu.org/software/coreutils/echo> or available locally via: info '(coreutils) echo invocation' GNU coreutils 8.28 January 2018 ECHO(1)
All times are GMT -4. The time now is 04:06 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy