File: www.sh

package info (click to toggle)
shoop 0.1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 328 kB
  • ctags: 41
  • sloc: sh: 1,138; makefile: 209; perl: 44
file content (32 lines) | stat: -rw-r--r-- 771 bytes parent folder | download
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
#!/bin/sh -e

# LGPL copyright 2000 by Adam Heath <doogie@debian.org>

## Creates a new WWW object.  C<WWW . fetch>(a simplistic wrapper around
## wget) expects a list of (I<url> I<file>) pairs.  C<WWW . finished>
## checks the passed filename to see if it has I<E<lt>/htmlE<gt>> in it,
## which should mean the page was built properly.  This is used to
## detect errors in dynamically generated pages.

OBJECT . new WWW

WWW . fetch : '
	local url file output return
	while [ $# -gt 0 ]; do
		url="$1" file="$2"; shift 2
		if [ "$file" ]; then
			file="-O $file"
		fi
		if ! wget -q $file $url 2>&1; then
			return 1
		fi
	done
'

WWW . finished : '
	local tmp=${2:-$($THIS . tmpfile1)} return
	$THIS . fetch $1 $tmp
	if ! grep -qi "</html>" $tmp; then
		return 1
	fi
'