Validate External Links
by Iritscen

The ValExtLinks script is a Bash shell script developed on a Mac, but hopefully any Bash shell from v3.2 onward can run it.  Non-Bash shells will not work, as there is a lot of Bash-specific syntax in this script.  The script invokes Unix binaries that are mostly pretty standard, but you might want to make sure that you have "curl" and "expect" installed.

The purpose of this read-me is not to tell you how to use the script.  Running the script with the --help option should give you that information.  This read-me simply intends to draw your attention to the following items that you may or will need to adapt to your system before you can use ValExtLinks:

- "Run validate_external_links.command" is intended to be the means of running the script.  The idea is to make sure this file is executable and then to double-click it (or invoke it from a cron event) when you want to run ValExtLinks.  First you will need to set the variables at the top of the script to be correct for your system.

- For testing and development, please note the following:
	- You can use the _LOCAL variables in "Run validate_external_links.command" to supply the exact links and exception files that you want the script to process.  Sample alternate invocations of ValExtLinks are also provided.
	- Currently, the extlinks.csv file hosted on oni2.net refreshes twice a day, at 06:20 and 14:20 GMT.
	- The "Sample files" folder contains:
		- archive-response.txt: a sample of the output of the Internet Archive's availability API.
		- extlinks.csv: the current format of oni2.net's wiki link dump.
		- header-redirect.txt: a sample of what "curl" sees when it is run with the --head option and gets a redirection (302) response.
		- header-ok.txt: a sample of what "curl" sees when it is run with the --head option and gets an OK (200) response.
		- ValExtLinks report.htm/.rtf/.txt: a reference sample of the output you should get.

- sftp_login.txt should be populated with your SFTP login info and the path that you want the report uploaded to.  The ValExtLinks script will parse this file and pass its info to val_expect_sftp.txt, which performs the actual upload of the ValExtLinks report.  The script was written to use SFTP because Oni2.net does not support regular FTP.

- The AGENT variable should contain a reasonably up-to-date user agent string, preferably generated from Google Chrome since that is the browser used to take screenshots of pages.  There are different web sites you can visit in the browser to learn the user agent string, or you can simply upload and then visit the supplied print_agent.php.

- The CURL_CODES and HTTP_CODES variables need to be set to wherever you are uploading those two files so that the reader can be directed to them properly from the header of the ValExtLinks report.

Have fun validating those external links!