1 |
3158
|
tao
|
#!/bin/sh
|
2 |
|
|
#This script will send a buildIndex command to
|
3 |
|
|
#remote metacat with docid parameter. Then metacat will build index for this docid.
|
4 |
|
|
#This script will have one argument - it is a text file name which contains docid list.
|
5 |
|
|
#The text file will look like
|
6 |
|
|
#nceas.1.1
|
7 |
|
|
#nceas.2.1
|
8 |
|
|
#nceas.3.1
|
9 |
|
|
|
10 |
|
|
if [ $# -ne 1 ]
|
11 |
|
|
then
|
12 |
|
|
echo "USAGE: $0 docidfile"
|
13 |
|
|
exit 1
|
14 |
|
|
fi
|
15 |
|
|
echo 'Please type metacat url (It should look like "http://pacific.msi.ucsb.edu:8080/knb/metacat")'
|
16 |
3162
|
tao
|
read metacatBaseURL
|
17 |
3158
|
tao
|
echo 'Please type KNB user name (It should look like "uid=tao,o=NCEAS,dc=ecoinformatics,dc=org")'
|
18 |
|
|
read username
|
19 |
|
|
echo 'Please type password'
|
20 |
|
|
read password
|
21 |
|
|
|
22 |
|
|
#login to metacat
|
23 |
3163
|
tao
|
loginurl="$metacatBaseURL?action=login&username=$username&password=$password"
|
24 |
3160
|
tao
|
wget -q -O - --save-cookies cookies --keep-session-cookies "$loginurl"
|
25 |
3158
|
tao
|
|
26 |
|
|
suffix="?action=buildindex"
|
27 |
3162
|
tao
|
metacatURL="$metacatBaseURL$suffix"
|
28 |
3158
|
tao
|
|
29 |
|
|
FILE=$1
|
30 |
|
|
# make sure file exist and readable
|
31 |
|
|
if [ ! -f $FILE ]; then
|
32 |
|
|
echo "$FILE : does not exists"
|
33 |
|
|
exit 1
|
34 |
|
|
elif [ ! -r $FILE ]; then
|
35 |
|
|
echo "$FILE: can not read"
|
36 |
|
|
exit 2
|
37 |
|
|
fi
|
38 |
|
|
|
39 |
|
|
|
40 |
|
|
index=0
|
41 |
|
|
length=3
|
42 |
|
|
# read $FILE using the file descriptors
|
43 |
|
|
exec 3<&0
|
44 |
|
|
exec 0<$FILE
|
45 |
|
|
while read line
|
46 |
|
|
do
|
47 |
|
|
if [ "$line" != "" ]
|
48 |
|
|
then
|
49 |
|
|
# construct metacat with given length of docid
|
50 |
|
|
metacatURL="$metacatURL&docid=$line"
|
51 |
|
|
index=`expr $index + 1`
|
52 |
|
|
if [ $index -eq $length ]
|
53 |
|
|
then
|
54 |
|
|
echo "here is url $metacatURL"
|
55 |
3160
|
tao
|
wget -q -O - --load-cookies cookies "$metacatURL"
|
56 |
3158
|
tao
|
index=0;
|
57 |
3162
|
tao
|
metacatURL="$metacatBaseURL$suffix"
|
58 |
3158
|
tao
|
fi
|
59 |
|
|
fi
|
60 |
|
|
done
|
61 |
|
|
|
62 |
|
|
#This will send out some remained docid
|
63 |
|
|
if [ $index -ne 0 ]
|
64 |
|
|
then
|
65 |
|
|
echo "here is url $metacatURL"
|
66 |
3160
|
tao
|
wget -q -O - --load-cookies cookies "$metacatURL"
|
67 |
3158
|
tao
|
fi
|
68 |
|
|
|
69 |
|
|
exec 0<&3
|
70 |
|
|
|
71 |
|
|
exit 0
|