#77 Identifying Broken Internal Links

The scripts in Chapter 7 highlighted the value and capabilities of the lynx text-only web browser, but there's even more power hidden within this tremendous software application. One capability that's particularly useful for a web administrator is the traverse function (which you enable by using -traversal), which causes lynx to try to step through all links on a site to see if any are broken. This feature can be harnessed in a short script.

The Code

#!/bin/sh

# checklinks - Traverses all internal 
 URLs on a website, reporting # any errors in the "traverse.errors" file. lynx="/usr/local/bin/lynx" # this might need to be tweaked # Remove all the lynx traversal output files upon completion: trap "/bin/rm ...

Get Wicked Cool Shell Scripts now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.