"Fossies" - the Fresh Open Source Software Archive 
Member "cb2bib-2.0.1/c2btools/bib2pdf" (12 Feb 2021, 3278 Bytes) of package /linux/privat/cb2bib-2.0.1.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
See also the latest
Fossies "Diffs" side-by-side code changes report for "bib2pdf":
2.0.0_vs_2.0.1.
1 #!/bin/sh
2 #-------------------------------------------------------------------------------
3 # bib2pdf -- Script to convert BibTeX files to PDF
4 # cb2Bib Tools
5 #
6 # Copyright (C) 2005-2021 by Pere Constans
7 # constans@molspaces.com
8 #
9 # Improvements and modifications:
10 # Copyright (C) 2009 by Filippo Rusconi
11 # rusconi@mnhn.fr
12 #
13 # May/June 2009:
14 # - Added checks to ensure that the used commands are available on
15 # system.
16 # - Make use of mktemp to create a temp directory.
17 #
18 # See LICENSE file that comes with this distribution
19 #
20 # Usage: bib2pdf input_bib output_pdf
21 #-------------------------------------------------------------------------------
22
23 #-------------------------------------------------------------------------------
24 # Init variables
25 #-------------------------------------------------------------------------------
26 # Modify accordingly, by choosing either pdflatex or latex+dvipdfm
27 #latexCmd=pdflatex
28 latexCmd=latex ; dvi2pdfCmd=dvipdfm
29
30 bibtexCmd=bibtex
31 #-------------------------------------------------------------------------------
32
33 # Immediately check that the needed programs are there:
34 "${latexCmd}" --version > /dev/null 2>&1
35
36 if [ "$?" != "0" ]
37 then
38 echo "Program ${latexCmd} (LaTeX software) is required."
39 echo "Ending processing."
40 exit 1
41 fi
42
43 "${bibtexCmd}" --version > /dev/null 2>&1
44
45 if [ "$?" != "0" ]
46 then
47 echo "Program ${bibtexCmd} (BibTeX software) is required."
48 echo "Ending processing."
49 exit 1
50 fi
51
52 # Special case with dvi2pdf:
53
54 if [ "x${dvi2pdfCmd}" != "x" ]
55 then
56 "${dvi2pdfCmd}" --version | head -n2 | grep dvipdfm > /dev/null 2>&1
57 if [ "$?" != "0" ]
58 then
59 echo "Program ${dvi2pdfCmd} (LaTeX software) is required."
60 echo "Ending processing."
61 exit 1
62 fi
63 fi
64
65
66 # Make sure we trap errors (we put that after the tests above because
67 # we need the tests to fail, in case, without exiting immediately).
68 set -e
69
70 # Getting filenames from command line
71 echo "cb2Bib Tools: Script to convert BibTeX to PDF"
72 if test "$#" != 2; then
73 cat <<EOF
74 Usage: $0 input_bib output_pdf
75 EOF
76 exit 2
77 fi
78
79
80 # Init some other variables (Modify accordingly) and create temporary
81 # directory.
82 latex_flags="-interaction=nonstopmode"
83 # Note that we use the mktemp utility that ensures that
84 # we do not overwrite any preexisting directory.
85 tmp_dir=$(mktemp -d --tmpdir c2b_tools_tmp.XXXXXXXX)
86
87
88 # Setting files
89 bib="$1"
90 pdf="$2"
91 work_dir="$PWD"
92
93 cat > "${tmp_dir}"/c2b_tmp.tex <<EOF
94 \documentclass[a4paper,10pt]{article}
95 %\documentclass[letterpaper,10pt]{article}
96 \pagenumbering{roman}
97 \bibliographystyle{unsrt}
98
99 \oddsidemargin 0.0in
100 \evensidemargin 1.0in
101 \textwidth 6.0in
102 \headheight 0.0in
103 \topmargin 0.in
104 \textheight 9.0in
105
106 \begin{document}
107
108 \nocite{*}
109 \bibliography{c2b_tmp}
110
111 \end{document}
112
113 EOF
114 cp "$bib" "${tmp_dir}"/c2b_tmp.bib
115
116 # LaTeX procedure (Modify accordingly)
117 cd "${tmp_dir}"
118 # There might be bibliography errors, do not stop.
119 set +e
120 "${latexCmd}" $latex_flags c2b_tmp > /dev/null 2>&1
121 "${bibtexCmd}" c2b_tmp
122 "${latexCmd}" $latex_flags c2b_tmp > /dev/null 2>&1
123 "${latexCmd}" $latex_flags c2b_tmp
124 if [ "x${dvi2pdfCmd}" != "x" ]
125 then
126 "${dvi2pdfCmd}" c2b_tmp > /dev/null 2>&1
127 fi
128
129 # Make sure we trap errors.
130 set -e
131
132 # Clean up
133 cd "${work_dir}"
134 cp "${tmp_dir}"/c2b_tmp.pdf "$pdf"
135 rm -rf "${tmp_dir}"
136 echo "$0 ended."