1
|
#!/bin/sh
|
2
|
|
3
|
# test-registry-submission.sh
|
4
|
#
|
5
|
#
|
6
|
# Created by Lauren Walker on 7/23/14.
|
7
|
#
|
8
|
# Replace the Cookie values or point to a file
|
9
|
|
10
|
> fileDetails.txt
|
11
|
> response.txt
|
12
|
|
13
|
counter="0"
|
14
|
|
15
|
while [ $counter -lt 5 ]
|
16
|
do
|
17
|
curl -X POST --cookie "JSESSIONID=XXX;CGISESSID=XXX" --form file_0=@testdata.csv --form cfg=metacatui --form stage=insert --form providerGivenName=Lauren --form providerSurName=Walker --form "title=test registry with curl $counter" --form site=NCEAS --form origNamefirst0=walker --form origNamelast0=Walker --form abstract=abstract --form beginningYear=2014 --form geogdesc=Cali --form latDeg1=0 --form longDeg1=0 --form dataMedium=digital --form "useConstraints=no restrictions" --form useOrigAddress=on --form scope=test --form fileCount=1 "https://dev.nceas.ucsb.edu/knb/cgi-bin/register-dataset.cgi" -o response.txt
|
18
|
|
19
|
upload=$(xmlstarlet sel -t -v "//input[@name='upload_0']/@value" response.txt)
|
20
|
uploadname=$(xmlstarlet sel -t -v "//input[@name='uploadname_0']/@value" response.txt)
|
21
|
uploadtype=$(xmlstarlet sel -t -v "//input[@name='uploadtype_0']/@value" response.txt)
|
22
|
|
23
|
echo "$upload,$uploadname,$uploadtype," >> fileDetails.txt
|
24
|
|
25
|
counter=$[$counter+1]
|
26
|
done
|
27
|
|
28
|
counter="0"
|
29
|
|
30
|
while [ $counter -lt 5 ]
|
31
|
do
|
32
|
details=$(tail -n+$counter fileDetails.txt | head -n1)
|
33
|
|
34
|
#Get the variables needed for the confirmation stage
|
35
|
commaLoc=`gexpr index $details ","`
|
36
|
upload=${details:0:commaLoc-1}
|
37
|
|
38
|
details=${details:commaLoc}
|
39
|
commaLoc=`gexpr index $details ","`
|
40
|
uploadname=${details:0:commaLoc-1}
|
41
|
|
42
|
details=${details:commaLoc}
|
43
|
commaLoc=`gexpr index $details ","`
|
44
|
uploadtype=${details:0:commaLoc-1}
|
45
|
|
46
|
curl -X POST --cookie "JSESSIONID=XXX;CGISESSID=XXX" --form file_0=@testdata.csv --form cfg=metacatui --form stage=confirmed --form providerGivenName=Lauren --form providerSurName=Walker --form "title=test registry with curl $counter" --form site=NCEAS --form origNamefirst0=walker --form origNamelast0=Walker --form abstract=abstract --form beginningYear=2014 --form geogdesc=Cali --form latDeg1=0 --form longDeg1=0 --form dataMedium=digital --form "useConstraints=no restrictions" --form useOrigAddress=on --form scope=test --form fileCount=1 --form upCount=1 --form delCount=1 --form uploadperm_0=public --form upload_0=$upload --form uploadname_0=$uploadname --form uploadtype_0=$uploadtype "https://dev.nceas.ucsb.edu/knb/cgi-bin/register-dataset.cgi" &
|
47
|
|
48
|
counter=$[$counter+1]
|
49
|
done
|
50
|
|