Batch Results Retrieval in curl
From Textserver wiki
1 #! /bin/sh
2
3 ########################################################################
4 #
5 # Example client to retrieve results for a batch job previously submitted
6 #
7 # Output will be a ZIP file containing results for each input file in
8 # the requested format (XML, json, conll)
9 #
10 ########################################################################
11
12 # Get query parameters
13 echo -n "TextServer username: "
14 read USERNAME
15 echo -n "TextServer Job Token ID: "
16 read TKID
17 echo -n "Output ZIP file: "
18 read OUTFNAME
19
20 TEXTSERVER_URL="http://frodo.lsi.upc.edu:8080/TextWS/textservlet/ws"
21
22 echo "Polling server for job completion..."
23 curl -X POST -s -S \
24 --form "username=$USERNAME" \
25 --form "tokenID=$TKID" \
26 $TEXTSERVER_URL"/resultRetrieve" >$OUTFNAME
27
28 if ( grep -q '\[TS-125\]' $OUTFNAME ); then
29 # server returned HTTP 503, with TextSErver code [TS-125], which means job not finished
30 echo "Job not finished yet"
31 rm $OUTFNAME
32 exit
33 elif ( grep -q '\[TS-' $OUTFNAME ); then
34 # some other error from TextServer
35 cat $OUTFNAME
36 echo ""
37 rm $OUTFNAME
38 exit
39 fi
40
41 # no error, we got the results.
42 echo "Job finished. Results saved to "$OUTFNAME