nbalonso.com

Script: Loop Sites and Get Http Response

| Comments

Brief post from the iPad to post a script to check the response of a website and display the http codes in colored output.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/sh

#gets the exit codes for 2x website builds
#.2026 seems to be the first valid build for 11.1 version

BUILDLOWER="2026"
BUILDHIGHER="2200"

while [[ ${BUILDLOWER} < ${BUILDHIGHER} ]]; do
  RESULT=`curl -s -o /dev/null -w "%{http_code}" http://www.2x.com/downloads/builds/applicationserver/11.1.${BUILDLOWER}/`
  if [[ ${RESULT} == "200" ]]; then
      #200 --> OK
      echo "http://www.2x.com/downloads/builds/applicationserver/11.1.${BUILDLOWER}/ --> `echo $&#039;\e[36m&#039; &#039;200&#039; $&#039;\e[0m&#039;`"
      curl -s http://www.2x.com/downloads/builds/applicationserver/11.1.${BUILDLOWER}/ --list-only | grep pkg
  elif [[ ${RESULT} == "300" ]]; then
      #300 --> Multiple Choices
      echo "http://www.2x.com/downloads/builds/applicationserver/11.1.${BUILDLOWER}/ --> `echo $&#039;\e[31m&#039; &#039;300&#039; $&#039;\e[0m&#039;`"
  elif [[ ${RESULT} == "301" ]]; then
      #301 --> Moved Permanently
      echo "http://www.2x.com/downloads/builds/applicationserver/11.1.${BUILDLOWER}/ --> `echo $&#039;\e[32m&#039; &#039;301&#039; $&#039;\e[0m&#039;`"
  fi
  BUILDLOWER=$[$BUILDLOWER+1]
done

echo "Finish!"

exit 0

Comments