On Friday 12 September 2008 10:46:04 am you wrote: > Steve Litt wrote: > > Anyway, the following is a script I use to compile a LyX book. It erases > > all the intermediate files, exports to LaTeX, runs latex on that, then > > runs dvips and ps2pdf to create the PDF. It also checks for compile > > errors by means of checking the length of one of the intermediate files. > > > > ================================================== > > #!/bin/bash > > lyxcommand=lyx-1.5.6 > > rm -f $1.aux > > rm -f $1.dvi > > rm -f $1.ps > > rm -f $1.pdf > > rm -f $1.idx > > rm -f $1.ilg > > rm -f $1.ind > > rm -f $1.log > > rm -f $1.tex > > rm -f $1.toc > > May I recommend: > EXTS="aux dvi ps pdf idx ilg ind log tex toc"; > for ext in $EXTS; do rm -f $1.$ext; done > Makes it just a touch simpler to maintain.
Beauty is in the eye of the beholder. I like the consecutive commands. Of course, if I repeatedly had to do different things to the different extensions, your method would be the clear winner. > > > $lyxcommand --export latex $1.lyx > > latex $1.tex > > makeindex $1.idx > > What does the next line test for? > > > ilglines=`wc -l $1.ilg | cut -d " " -f 1` The preceding command delivers the number of lines, and nothing more. Without the cut it would deliver something like: 6 mybook.ilg Of course, a simpler way to accomplish the same end would have been: cat $1.ilg | wc -l I was in a hurry when writing that script, and had half my mind on other things. > > if test "$ilglines" = "6"; then > > latex $1.tex > > latex $1.tex > > > > # Two commands below DO NOT ensure embedded fonts. > > # dvips -o $1.ps $1.dvi > > # ps2pdf12 $1.ps > > > > # Two commands below ensure all fonts embedded! > > dvips -t letter -Pdownload35 -o $1.ps $1.dvi > > ps2pdf12 -dEmbedAllFonts=true $1.ps > > #nohup gv $1.pdf & > > #exit 0 > > I take it that you want to be able to use both of these. No, I just forgot to remove the non-embedding commands. When selling Ebooks to people on unknown systems, I always try to have the PDF be as standalone as possible. > If so, then (as > I'm sure you know) you can do it with option processing. Put this at the > beginning: > EMBED=""; > while getopts ":e" opt; do > case $opt in > e) EMBED="true";; > \?) echo "Unrecognized option: " $opt; exit 1;; > esac > done > And then later you can have: > if [ -z "$EMBED" ]; then > # do the non-embed thing > else > # do the embed thing > fi That's good info! I've used getopts only in C and Ruby and maybe Perl. I didn't know you could do it in shellscripts. STeveT Steve Litt Recession Relief Package http://www.recession-relief.US
