File:  [LON-CAPA] / doc / help / render.texxml.pl
Revision 1.15: download - view: text, annotated - select for diffs
Tue Sep 2 18:29:58 2003 UTC (20 years, 9 months ago) by bowersj2
Branches: MAIN
CVS tags: HEAD
Terminate renders on failure. (And some other crap, notably a hack for
pod2latex to work on files like "lonsql" that don't have .pm.)

    1: # The LearningOnline Network with CAPA
    2: # Perl script to render texxml files to a dvi
    3: #
    4: # Copyright Michigan State University Board of Trustees
    5: #
    6: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
    7: #
    8: # LON-CAPA is free software; you can redistribute it and/or modify
    9: # it under the terms of the GNU General Public License as published by
   10: # the Free Software Foundation; either version 2 of the License, or
   11: # (at your option) any later version.
   12: #
   13: # LON-CAPA is distributed in the hope that it will be useful,
   14: # but WITHOUT ANY WARRANTY; without even the implied warranty of
   15: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   16: # GNU General Public License for more details.
   17: #
   18: # You should have received a copy of the GNU General Public License
   19: # along with LON-CAPA; if not, write to the Free Software
   20: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   21: #
   22: # /home/httpd/html/adm/gpl.txt
   23: #
   24: # http://www.lon-capa.org/
   25: #
   26: # 7-16-2002 Jeremy Bowers
   27: 
   28: use strict;
   29: use Fcntl;
   30: use POSIX qw(tmpnam);
   31: 
   32: if ( scalar(@ARGV) < 2 )
   33: {
   34:     print (<<USAGE);
   35: Usage: $0 texxml_file_name or
   36:        perl $0 -- texxml_file_name
   37:        where "texxml_file_name" optionally includes the extension
   38: Output: texxml_file_name.dvi
   39: 
   40: $0 renders texxml files into dvi files by copying the tex file
   41: resulting from from texxml2latex.pl and the referenced eps files
   42: into a temporary directory and running LaTeX on the .tex file.
   43: 
   44: If a second argument is passed, it is used as the location of the 
   45: .eps files the document uses.
   46: 
   47: Must be run as somebody with permissions to write temp files and 
   48: access /home/httpd/html/adm/help/eps.
   49: USAGE
   50: 
   51:     exit();
   52: }
   53: 
   54: my $tmpdir = tmpnam();
   55: my $fileroot = $ARGV[1];
   56: 
   57: if (substr($fileroot, -7) eq ".texxml")
   58: {
   59:     $fileroot = substr($fileroot, 0, -7);
   60: }
   61: 
   62: my $epssource = "../../loncom/html/adm/help/eps";
   63: 
   64: if ( defined ( $ARGV[2] ) ) # override eps source, for build on install
   65: {
   66:     $epssource = $ARGV[2];
   67: }
   68: 
   69: #my $redir = ">& /dev/null"; # empty this for easier debugging
   70: my $redir = ">> /home/jerf/error_log.txt";
   71: 
   72: mkdir $tmpdir, 0755;
   73: 
   74: print "Converting texxml to tex...\n";
   75: if (system ( "perl texxml2latex.pl $fileroot.texxml > $tmpdir/$fileroot.tex" )) {
   76:     $! = 1;
   77:     die "Terminated render because texxml2latex failed; see previous error message.";
   78: };
   79: 
   80: print "Copying .eps files...\n";
   81: system ( "cp $epssource/* $tmpdir/" );
   82: 
   83: print "Running Latex...\n";
   84: system ( "cd $tmpdir; echo | latex $fileroot $redir; echo | latex $fileroot $redir; makeindex $fileroot.idx; echo | latex $fileroot\ $redir; " );
   85: 
   86: print "Running dvips...\n";
   87: system ( "cd $tmpdir; dvips -Ppdf -G0 -f $fileroot.dvi > $fileroot.ps  " );
   88: 
   89: print "Copying ps file...\n";
   90: system ( "cp $tmpdir/$fileroot.ps .");
   91: 
   92: print "Converting to PDF (may take a bit)...\n";
   93: system ( "ps2pdf $fileroot.ps $fileroot.pdf" );
   94: 
   95: print "Clearing temp directory...\n";
   96: system ( "rm -rf $tmpdir" );
   97: 
   98: if ( -e $fileroot . ".ps" )
   99: {
  100:     print "$fileroot.ps and $fileroot.pdf are ready.\n";
  101: }
  102: else
  103: {
  104:     print "Generationr of $fileroot.ps failed.\n";
  105: }

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>
500 Internal Server Error

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator at root@localhost to inform them of the time this error occurred, and the actions you performed just before this error.

More information about this error may be available in the server error log.