source: trunk/linkchecker.sh @ 54

Last change on this file since 54 was 53, checked in by pinsard, 16 years ago

usage of ploticus instead of gnuplot for plot

  • Property svn:keywords set to Id
File size: 3.5 KB
Line 
1#! /bin/sh -x
2#
3# module :
4# check links of a given directory or url
5# cf. install.sh
6#
7# original location :
8# /usr/home/fplod/src/superbib_ws/linkchecker.sh sur aedon.locean-ipsl.upmc.fr
9#
10# update :
11# ++ linkchecker ne voit pas les erreurs !!
12# ++ dirpublish forme fplod@cerbere.locean-ipsl.upmc.fr:./WWW/ par example
13# donc pas http
14# + ajouter la possibilite de faire une carte du site avec
15# graphiz
16# exemple syntaxe =
17# $ linkchecker -odot -v http://www.lodyc.jussieu.fr/NEMO/general/biblio_new/   | dot -Tps > sitemap.ps
18#
19# remove "set -u" because I don't know how to test if there is at least
20# one directory AND one url to be checked without this option
21# !! ++ must be restore ASAP
22# $Id$
23# fplod 2007-10-12T07:32:08Z aedon.locean-ipsl.upmc.fr (Darwin)
24# add -u pour url
25# add multiple -d and suppression of interactivity
26# replace -w by -d (more generic)
27# use rather checklink than linkchecker because the first one exist either
28# on Mac and Unix, and because the second one exists only on Mac and
29# does'nt seem to detect every problem
30# fplod 2007-10-11T15:31:25Z aedon.locean-ipsl.upmc.fr (Darwin)
31# parametrization
32# merge with checklink.sh ++ choisir entre les deux
33# fplod 2007-06-19T09:26:04Z aedon.locean-ipsl.upmc.fr (Darwin)
34# création
35#
36set -o posix
37command=$(basename ${0} .sh)
38log_date=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
39log=/tmp/${command}.log.${log_date}
40#
41usage=" Usage : ${command} -d dircheck -u url"
42#
43minargcount=2
44#echo " narg ${#}"
45if [ ${#} -lt ${minargcount} ]
46then
47  echo "eee : not enought arguments"
48  echo "${usage}"
49  exit 1
50fi
51#
52idircheck=0
53iurl=0
54while [ ! -z "${1}" ]
55do
56 case ${1} in
57 -d)
58  idircheck=$(( ${idircheck} + 1 ))
59  dircheck[${idircheck}]=${2}
60  shift
61 ;;
62 -u)
63  iurlcheck=$(( ${iurlcheck} + 1 ))
64  urlcheck[${iurlcheck}]=${2}
65  shift
66 ;;
67 esac
68 shift # next flag
69done
70#
71# +++ remove temporarily
72# +++ set -u
73#
74# ++ check directories or URL
75#
76# choose the command to be used
77#
78commandcheck=checklink
79#
80if [ ${commandcheck} = "linkchecker" ]
81then
82   # test if linkchecker is available
83   type ${commandcheck} 1> /dev/null 2>&1
84   status=${?}
85   if [ ${status} -ne 0 ]
86   then
87    echo "${command} : eee : ${commandcheck} unavailable"
88    exit 1
89   fi
90   optcheck="--anchors --recursion-level=-1"
91fi
92#
93if [ ${commandcheck} = "checklink" ]
94then
95   # test if checklink is available
96   type ${commandcheck} 1> /dev/null 2>&1
97   status=${?}
98   if [ ${status} -ne 0 ]
99   then
100      echo "${command} : eee : ${commandcheck} unavailable"
101      exit 1
102   fi
103#
104   optcheck="--summary --recursive"
105fi
106#
107# loop on directories to be checked
108dirchecksize=${#dircheck[@]} # ++ pb set -u
109if [ ${dirchecksize} -gt 0 ]
110then
111   idircheck=1
112   while [ ${idircheck} -le ${dirchecksize} ]
113   do
114      echo "iii : beginning of check of ${dircheck[${idircheck}]}" 1>>${log}
115      fverif="file://"${dircheck[${idircheck}]}
116      echo "iii : check of ${fverif}"
117      ${commandcheck} ${optcheck} ${fverif} 1>>${log} 2>&1
118      idircheck=$(( ${idircheck} + 1 ))
119   done
120fi
121#
122# loop on urls to be checked
123urlchecksize=${#urlcheck[@]} # ++ pb set -u
124if [ ${urlchecksize} -gt 0 ]
125then
126   iurlcheck=1
127   while [ ${iurlcheck} -le ${urlchecksize} ]
128   do
129      echo "iii : beginning of check of ${urlcheck[${iurlcheck}]}" 1>>${log}
130      # ++ test si urlcheck commence par http ou pas
131      fverif=${urlcheck[${iurlcheck}]}
132      echo "iii : check of ${fverif}"
133      ${commandcheck} ${optcheck} ${fverif} 1>>${log} 2>&1
134      iurlcheck=$(( ${iurlcheck} + 1 ))
135   done
136fi
137#
138echo "iii : log in ${log}"
139# end
140exit
Note: See TracBrowser for help on using the repository browser.