Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.