source: branches/bibliolocean/src/biblio_check.sh @ 226

Last change on this file since 226 was 117, checked in by pinsard, 12 years ago

add a branch for LOCEAN bibliography

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Id URL
File size: 3.3 KB
Line 
1#! /bin/sh
2#+
3#
4# ===============
5# biblio_check.sh
6# ===============
7#
8# ------------------------
9# check a biblio directory
10# ------------------------
11#
12# SYNOPSIS
13# ========
14#
15# ``biblio_check.sh -i biblio_dir -o dirout``
16#
17# DESCRIPTION
18# ===========
19#
20# Lauch jabref on each individual file (bibtex convention syntax) of biblio_dir
21#
22# -i  input directory
23# -o  output directory
24#
25# Each file of the output directory is named after the bibtex file.
26#
27# ++ log file
28#
29# EXAMPLES
30# ========
31#
32# To check the biblio of LOCEAN::
33#
34#  $ biblio_check.sh -i /tmp/locean_biblio_split/ -o /tmp/locean_biblio_check/
35#
36# TODO
37# ====
38#
39#
40# EVOLUTIONS
41# ==========
42#
43# $Id$
44#
45# - fplod 20110301T100911Z aedon.locean-ipsl.upmc.fr (Darwin)
46#
47#   * jaberef_dir=f(uname -s)
48#
49# - fplod 20091019T085114Z aedon.locean-ipsl.upmc.fr (Darwin)
50#
51#   * creation
52#
53#-
54#
55system=$(uname)
56case "${system}" in
57   AIX|IRIX64)
58      echo " www : no specific posix checking"
59   ;;
60   *)
61      set -o posix
62   ;;
63esac
64#
65command=$(basename ${0})
66log_date=$(date -u +"%Y%m%dT%H%M%SZ")
67#
68usage=" Usage : ${command} -i biblio_dir -o dirout"
69#
70# default
71jabref_version="2.6"
72jabref_dir="/usr/home/incas/francoise/jabref-${jabref_version}_$(hostname)/"
73case "$(uname -s)" in
74   Darwin)
75      jabref_dir=${jabref_dir}"JabRef.app/Contents/Resources/Java/"
76   ;;
77   Linux)
78   ;;
79   *)
80      echo "${command} : eee : unknown system $(uname -s)"
81   ;;
82esac
83#
84tmpdir=/tmp/${LOGNAME}/gtbiblio
85mkdir -p /tmp/${LOGNAME}/gtbiblio/
86# artificial header of jabref file to enforce encoding
87{
88echo "% This file was articifialy created for JabRef ${jabref_version}."
89echo "% Encoding: ISO8859_1"
90echo " "
91} > ${tmpdir}/header_jabref
92#
93minargcount=4
94if [ ${#} -lt ${minargcount} ]
95then
96   echo "eee : ${command} : not enought arguments"
97   echo "${usage}"
98   exit 1
99fi
100#
101set +u
102while [ ! -z "${1}" ]
103do
104   case ${1} in
105      -i)
106         biblio_dir=${2}
107         shift
108      ;;
109      -o)
110         dirout=${2%/}
111         shift
112      ;;
113      -h)
114         echo "${usage}"
115         exit 0
116      ;;
117      *)
118         # anything else
119         echo "eee : unknown option ${1}"
120         echo "eee : ${usage}"
121         exit 1
122      ;;
123   esac
124   # next flag
125   shift
126done
127#
128set -u
129#
130# check for biblio_dir
131if [ ! -d ${biblio_dir} ]
132then
133   echo "eee : ${command} : ${biblio_dir} not accessible"
134   exit 1
135fi
136#
137# check for dirout
138# the idea is to prevent unwanted overwrite
139if [ -d ${dirout} ]
140then
141   echo "eee : ${command} : ${dirout} already exist"
142   exit 1
143else
144   mkdir -p ${dirout}
145   if [ ${?} -ne 0 ]
146   then
147      echo "eee : ${command} : cannot create ${dirout}"
148      exit 1
149   fi
150fi
151#
152# loop on each file of ${biblio_dir} ie files to be checkted
153format=locean_listrefs
154for bibtex_file in ${biblio_dir}/*.bib
155do
156   echo "bibtex_file = ${bibtex_file}"
157   filein=${tmpdir}/$(basename ${bibtex_file})
158   cat ${tmpdir}/header_jabref ${bibtex_file} > ${filein}
159   output_file=${dirout}/$(basename ${bibtex_file} .bib).html
160   java -jar ${jabref_dir}/JabRef-${jabref_version}.jar -n true \
161      -p ./jabref.preferences.xml \
162      --output ${output_file},${format} \
163      ${filein}
164   jabref_status=${?}
165   if [ ${jabref_status} -ne 0 ]
166   then
167      echo "eee : ${command} : pb with jabref export ${bibtex_file}"
168      exit 1
169   fi
170done
171#
172echo "iii : ${biblio_dir} is checked in ${dirout}"
173#
174# clean
175#++rm -rf ${tmpdir}
176# end
177exit 0
Note: See TracBrowser for help on using the repository browser.