Wednesday, May 11, 2011

Bash script to verify urls

This will check a list of urls contained in a file and only output any errors. (Requires curl)


#!/bin/bash
FILE=$1
exec 3<&0
exec 0<$FILE
while read line
do
/usr/bin/curl -silent -S -f $line --connect-timeout 3 > /dev/null || echo -e $line "\n\n"
done
exec 0<&3
Usage: ./checkurls.sh urlfile

Your url file should like something like:

http://www.google.com
http://www.google.com/testurl
mondotech.blogspot.com
mondotech.org

No comments: