dotfiles

My personal shell configs and stuff
git clone git://git.alex.balgavy.eu/dotfiles.git
Log | Files | Refs | Submodules | README | LICENSE

checklinks (578B)


      1 #!/bin/sh
      2 # Script that crawls a URL and checks broken links
      3 set -x
      4 if ! command -v wget 1>/dev/null 2>&1; then
      5   echo "Please install wget."
      6   exit 1
      7 elif [ $# -ne 2 ]; then
      8   echo "Usage:"
      9   echo "checklinks [URL] [LOGFILE]"
     10   exit 1
     11 fi
     12 
     13 # params: LOGFILE, URL
     14 wget_with_flags() { wget --spider --recursive --no-directories --no-verbose --page-requisites --level inf --wait 2 -e robots=off -o "$2" "$1"; }
     15 # flags=(--spider --recursive --no-directories --no-verbose --page-requisites --level inf -e robots=off)
     16 
     17 wget_with_flags "$2" "$1"
     18 
     19 grep -B 1 'broken link!' "$2" | less