Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm looking for a shell script to check a list of URLs and give output. For example:

http://abc.com/index.php
http://abc1.com/index.php

I may place them in a separate file or inside the script. I need a valid HTTP response code for all these URLs. If all the URLs work, the response code must be HTTP OK HTTP/1.1 200 OK.

If any URL from the above URLs fails, I need output with an error message for that particular URL.

share|improve this question

You will have to install wget is you don't have it already:

#!/bin/bash
IFS='
'
LIST='http://www.google.com
http://www.drk.com.ar/daphne.php
http://www.google.com/this-is-an-error
http://serverfault.com/questions
'
for I in $LIST
do
  wget -q --no-cache --spider $I
  if [ $? != 0 ]; then
    echo Error: $I
  fi
done
share|improve this answer

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .