-
Notifications
You must be signed in to change notification settings - Fork 0
/
69-checklinks
33 lines (24 loc) · 912 Bytes
/
69-checklinks
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
28
29
30
31
32
33
#!/bin/bash
# checklinks--Traverses all internal URLs on a website, reporting
# any errors in the "traverse.errors" file.
# Remove all the lynx traversal output files upon completion.
trap "`which rm` -f traverse.dat traverse2.dat" 0
if [ -z "$1" ] ; then
echo "Usage: checklinks URL" >&2 ; exit 1
fi
baseurl="$(echo $1 | cut -d/ -f3 | sed 's/http:\/\///')"
lynx -traversal -accept_all_cookies -realm "$1" > /dev/null
if [ -s "traverse.errors" ] ; then
echo -n $(wc -l < traverse.errors) errors encountered.
echo Checked $(grep '^http' traverse.dat | wc -l) pages at ${1}:
sed "s|$1||g" < traverse.errors
mv traverse.errors ${baseurl}.errors
echo "(A copy of this output has been saved in ${baseurl}.errors)"
else
echo -n "No errors encountered. ";
echo Checked $(grep '^http' traverse.dat | wc -l) pages at ${1}
fi
if [ -s "reject.dat" ]; then
mv reject.dat ${baseurl}.rejects
fi
exit 0