-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path404.sh
More file actions
executable file
·34 lines (25 loc) · 723 Bytes
/
Copy path404.sh
File metadata and controls
executable file
·34 lines (25 loc) · 723 Bytes
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
34
#!/usr/bin/env bash
#
# Check for internal 404s
# Strict settings
set -o errexit
set -o pipefail
set -o nounset
# "Magic" variables
__dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
__file="${__dir}/$(basename "${BASH_SOURCE[0]}")"
__base="$(basename "${__file}" .sh)"
if ! command -v wget >/dev/null 2>&1; then
echo "wget is not installed"
exit 1
fi
domain=${1:-}
if [ -z "$domain" ]; then
echo "Usage: $__base.sh <domain>"
exit 1
fi
output="$__dir/$domain.$__base.txt"
wget --spider --recursive --no-parent --no-verbose --output-file="$output" "$domain" >/dev/null 2>&1
errors=$(grep -c "404 Not Found" "$output" || true)
echo "Number of 404 errors found: $errors"
[[ $errors == 0 ]] && rm "$output"