Annotation of loncom/interface/printout.pl, revision 1.71
1.1 sakharuk 1: #!/usr/bin/perl
1.37 albertel 2: # CGI-script to run LaTeX, dvips, ps2ps, ps2pdf etc.
3: #
1.71 ! albertel 4: # $Id: printout.pl,v 1.70 2004/11/13 08:25:41 albertel Exp $
1.37 albertel 5: #
6: # Copyright Michigan State University Board of Trustees
7: #
8: # This file is part of the LearningOnline Network with CAPA (LON-CAPA).
9: #
10: # LON-CAPA is free software; you can redistribute it and/or modify
11: # it under the terms of the GNU General Public License as published by
12: # the Free Software Foundation; either version 2 of the License, or
13: # (at your option) any later version.
14: #
15: # LON-CAPA is distributed in the hope that it will be useful,
16: # but WITHOUT ANY WARRANTY; without even the implied warranty of
17: # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18: # GNU General Public License for more details.
19: #
20: # You should have received a copy of the GNU General Public License
21: # along with LON-CAPA; if not, write to the Free Software
22: # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23: #
24: # /home/httpd/html/adm/gpl.txt
25: #
26: # http://www.lon-capa.org/
27: #
28:
1.39 sakharuk 29: use lib '/home/httpd/lib/perl';
30: use LONCAPA::loncgi();
1.38 sakharuk 31: use File::Path;
1.6 sakharuk 32: use IO::File;
1.7 sakharuk 33: use Image::Magick;
1.47 sakharuk 34: use Apache::lonhtmlcommon;
1.71 ! albertel 35: use Apache::lonnet();
1.51 albertel 36: use Apache::loncommon;
37: use Apache::lonlocal;
1.47 sakharuk 38:
1.59 albertel 39: use strict;
1.49 albertel 40: $|=1;
1.46 albertel 41: my %origENV=%ENV;
1.39 sakharuk 42: if (! &LONCAPA::loncgi::check_cookie_and_load_env()) {
43: print <<END;
44: Content-type: text/html
45:
46: <html>
47: <head><title>Bad Cookie</title></head>
48: <body>
1.40 sakharuk 49: Your cookie information is incorrect.
1.39 sakharuk 50: </body>
51: </html>
52: END
53: return;
54: }
1.51 albertel 55: &Apache::lonlocal::get_language_handle();
56: &Apache::loncommon::content_type(undef,'text/html');
57: my $bodytag=&Apache::loncommon::bodytag('Creating PDF','','');
58: print $bodytag;
1.39 sakharuk 59:
1.40 sakharuk 60: my $identifier = $ENV{'QUERY_STRING'};
61: my $texfile = $ENV{'cgi.'.$identifier.'.file'};
62: my $laystyle = $ENV{'cgi.'.$identifier.'.layout'};
63: my $numberofcolumns = $ENV{'cgi.'.$identifier.'.numcol'};
1.62 sakharuk 64: my $paper = $ENV{'cgi.'.$identifier.'.paper'};
1.40 sakharuk 65: my $selectionmade = $ENV{'cgi.'.$identifier.'.selection'};
66: my $tableofcontents = $ENV{'cgi.'.$identifier.'tableofcontents'};
67: my $tableofindex = $ENV{'cgi.'.$identifier.'tableofindex'};
68: my $advans_role = $ENV{'cgi.'.$identifier.'role'};
1.43 sakharuk 69: my $number_of_files = $ENV{'cgi.'.$identifier.'numberoffiles'}+1;
1.44 sakharuk 70: my $student_names = $ENV{'cgi.'.$identifier.'studentnames'};
1.71 ! albertel 71: my $backref = &Apache::lonnet::unescape($ENV{'cgi.'.$identifier.'backref'});
1.43 sakharuk 72:
1.62 sakharuk 73:
1.49 albertel 74: my $adv = $ENV{'request.role.adv'};
75:
1.44 sakharuk 76: my @names_pack=();
77: if ($student_names=~/_END_/) {
78: @names_pack=split(/_ENDPERSON_/,$student_names);
79: }
1.46 albertel 80: #got what we needed reset ENV in case it is to big for system
81: %ENV=%origENV;
1.39 sakharuk 82:
1.14 sakharuk 83: my $figfile = $texfile;
84: $figfile =~ s/^([^\.]+printout)[^t]+\.tex/$1\.dat/;
85: my $duefile = $texfile;
86: $duefile =~ s/^([^\.]+printout)[^t]+\.tex/$1\.due/;
87: #do we have figures?
88: if (-e $figfile) {
1.42 albertel 89: my %done_conversion;
1.69 matthew 90: my $temporary_file=IO::File->new($figfile) || die "Couldn't open fig file $figfile for reading: $!\n";
1.14 sakharuk 91: my @content_of_file = <$temporary_file>;
92: close $temporary_file;
93: my $noteps;
1.49 albertel 94: my %prog_state;
1.59 albertel 95: if ($adv) { %prog_state=&Apache::lonhtmlcommon::Create_PrgWin('','Coverting Images to EPS','Picture Conversion Status',$#content_of_file,'inline','80'); }
96: foreach my $not_eps (@content_of_file) {
1.49 albertel 97: chomp($not_eps);
1.14 sakharuk 98: if ($not_eps ne '') {
1.44 sakharuk 99: my $status_statement='EPS picture for '.$not_eps;
1.41 sakharuk 100: $not_eps=~s|\/\.\/|\/|g;
1.14 sakharuk 101: my $eps_f = $not_eps;
102: $eps_f =~ s/\.[^.]*$/\.eps/i;
1.41 sakharuk 103: if ($eps_f=~/\/home\/([^\/]+)\/public_html\//) {
104: $eps_f=~s/\/home\/([^\/]+)\/public_html/$1/;
105: $eps_f = '/home/httpd/prtspool/'.$eps_f;
1.58 sakharuk 106: } elsif ($eps_f=~/$Apache::lonnet::perlvar{'lonDocRoot'}\/res\//) {
107: $eps_f=~m/$Apache::lonnet::perlvar{'lonDocRoot'}\/res\/(.+)/;
1.41 sakharuk 108: $eps_f = '/home/httpd/prtspool/'.$1;
1.58 sakharuk 109: } elsif ($eps_f=~/$Apache::lonnet::perlvar{'lonUsersDir'}\//) {
1.57 sakharuk 110: $eps_f=~/$Apache::lonnet::perlvar{'lonUsersDir'}\/([^\/]+)\/\w\/\w\/\w\/(.+)/;
1.56 sakharuk 111: $eps_f = '/home/httpd/prtspool/'.$1.'/'.$2;
1.41 sakharuk 112: }
1.38 sakharuk 113: my $path=$eps_f;
1.41 sakharuk 114: $path=~s/\/([^\/]+)\.eps$//;
1.38 sakharuk 115: File::Path::mkpath($path,0,0777);
1.14 sakharuk 116: my $image = Image::Magick->new;
117: $not_eps =~ s/^\s+//;
118: $not_eps =~ s/\s+$//;
1.42 albertel 119: if ( exists($done_conversion{$not_eps})) {
120: next;
121: }
1.49 albertel 122: if ($adv) {
123: my $prettyname=$not_eps;
124: $prettyname=~s|/home/([^/]+)/public_html|/priv/$1|;
1.58 sakharuk 125: $prettyname=~s|$Apache::lonnet::perlvar{'lonDocRoot'}/|/|;
1.49 albertel 126: &Apache::lonhtmlcommon::Update_PrgWin('',\%prog_state,'Converting to EPS '.$prettyname); }
1.42 albertel 127: $done_conversion{$not_eps}=1;
1.59 albertel 128: my $status = $image->Read($not_eps);
1.14 sakharuk 129: if ($status) {print " $status ";}
130: $image->Set(page => '+100+200');
131: $status = $image->Write($eps_f);
132: if ($status) {print " $status ";}
1.20 sakharuk 133: #check is eps exist in prtspool
134: if(not -e $eps_f) {
135: for (my $i=0;$i<10000;$i++) {
136: if (-e $eps_f.'.'.$i) {
137: rename $eps_f.'.'.$i, $eps_f;
138: last;
139: }
140: }
141: }
1.14 sakharuk 142: }
143: }
1.49 albertel 144: if ($adv) { &Apache::lonhtmlcommon::Close_PrgWin('',\%prog_state); }
1.52 albertel 145: unlink($figfile);
1.14 sakharuk 146: }
1.43 sakharuk 147: #print "$texfile\n"; #name of the tex file for debugging only
148: my @texfile=($texfile);
149: if ($number_of_files>1) {
1.49 albertel 150: @texfile=();
151: for (my $i=1;$i<=$number_of_files;$i++) {
1.43 sakharuk 152: my $new_texfile=$texfile;
1.49 albertel 153: $new_texfile=~s/\.tex/_$i\.tex/;
1.43 sakharuk 154: push @texfile,$new_texfile;
155: }
156: }
1.49 albertel 157:
1.44 sakharuk 158: my $ind=-1;
1.49 albertel 159: my %prog_state;
1.61 albertel 160: print "<a href=\"$backref\"><b>Return</b></a> to last resource.<br /><br />";
1.59 albertel 161: if ($adv) { %prog_state=&Apache::lonhtmlcommon::Create_PrgWin('','Print Status','Class Print Status',$number_of_files,'inline','80'); }
1.61 albertel 162: print "<br />";
1.43 sakharuk 163: foreach $texfile (@texfile) {
1.49 albertel 164: my $status_statement='';
165: my $link_text='download PDF';
166: $ind++;
167: my @stud_info=split(/_END_/,$names_pack[$ind]);
168: my @tempo_array=split(/:/,$stud_info[0]);
169: my $name;
170: if ($tempo_array[3]) {
171: $name=$tempo_array[3];
172: } else {
173: $name=$tempo_array[0].'@'.$tempo_array[1];
174: }
1.61 albertel 175: $link_text='<b>'.$name.'</b>';
1.49 albertel 176: $status_statement.=$name;
177: if ($#stud_info>0) {
178: @tempo_array=split(/:/,$stud_info[-1]);
1.48 albertel 179: if ($tempo_array[3]) {
180: $name=$tempo_array[3];
181: } else {
182: $name=$tempo_array[0].'@'.$tempo_array[1];
183: }
1.61 albertel 184: $link_text.=' - <b>'.$name.'</b>';
1.49 albertel 185: $status_statement.=' - '.$name;
186: }
187: if ($adv) { &Apache::lonhtmlcommon::Update_PrgWin('',\%prog_state,'Creating PDF for '.$status_statement); }
1.29 sakharuk 188: if (-e $texfile) {
189: $texfile =~ m/^(.*)\/([^\/]+)$/;
190: my $name_file = $2;
191: my $path_file = $1.'/';
192: chdir $path_file;
1.59 albertel 193: my $dvi_file= $name_file; $dvi_file =~ s/\.tex/\.dvi/;
194: &busy_wait_command("latex $name_file 1>/dev/null 2>/dev/null",
195: "for $status_statement now LaTeXing file",
196: \%prog_state,$dvi_file);
1.40 sakharuk 197: if ($tableofcontents eq 'yes') {
1.63 sakharuk 198: &busy_wait_command("latex $name_file 1>/dev/null 2>/dev/null",
199: "for $status_statement now LaTeXing file for table of contents",
200: \%prog_state,$dvi_file);
1.40 sakharuk 201: } #to create table of contents
1.33 sakharuk 202: my $idxname=$name_file;
203: $idxname=~s/\.tex$/\.idx/;
1.40 sakharuk 204: if ($tableofindex eq 'yes') {
1.63 sakharuk 205: &busy_wait_command("makeindex $idxname",
206: "making index file",
207: \%prog_state,$idxname);
208: &busy_wait_command("latex $name_file 1>/dev/null 2>/dev/null",
209: "for $status_statement now LaTeXing file for index section",
210: \%prog_state,$dvi_file);
1.33 sakharuk 211: } #to create index
1.29 sakharuk 212: #Do we have a latex error in the log file?
1.67 sakharuk 213: my $logfilename = $texfile; $logfilename =~ s/\.tex$/\.log/;
1.69 matthew 214: my $temporary_file=IO::File->new($logfilename) || die "Couldn't open log file $logfilename for reading: $!\n";
1.29 sakharuk 215: my @content_of_file = <$temporary_file>;
216: close $temporary_file;
1.30 sakharuk 217: my $body_log_file = join(' ',@content_of_file);
218: $logfilename =~ s/\.log$/\.html/;
219: $temporary_file = IO::File->new('>'.$logfilename);
220: print $temporary_file '<html><head><title>LOGFILE</title></head><body><pre>'.$body_log_file.'</pre></body></html>'."\n";
1.29 sakharuk 221: if ($body_log_file=~m/!\s+Emergency stop/) {
222: #LaTeX failed to parse tex file
223: print "<h2>LaTeX could not successfully parse your tex file.</h2>";
224: print "It probably has errors in it.<br />";
225: my $whereitbegins = rindex $body_log_file,'STAMPOFPASSEDRESOURCESTART';
226: my $whereitends = rindex $body_log_file,'STAMPOFPASSEDRESOURCEEND';
227: if ($whereitbegins!=-1 and $whereitends!=-1) {
1.44 sakharuk 228: print "With very high probability this error occured in ".substr($body_log_file,$whereitbegins+26,$whereitends-$whereitbegins-26)."<br /><br />";
1.29 sakharuk 229: }
1.70 albertel 230: print "Here are the error messages in the LaTeX log file</br><br /><pre>";
1.29 sakharuk 231: my $sygnal = 0;
232: for (my $i=0;$i<=$#content_of_file;$i++) {
233: if ($content_of_file[$i]=~m/^Runaway argument?/ or $content_of_file[$i]=~m/^!/) {
234: $sygnal = 1;
235: }
236: if ($content_of_file[$i]=~m/Here is how much of/) {
237: $sygnal = 0;
238: }
239: if ($sygnal) {
1.70 albertel 240: print "$content_of_file[$i]";
1.29 sakharuk 241: }
1.36 sakharuk 242: }
1.70 albertel 243: print "</pre>\n";
1.36 sakharuk 244: if ($advans_role) {
1.35 sakharuk 245: print "<b><big>The link to ";
246: $logfilename=~s/\/home\/httpd//;
247: print "<a href=\"$logfilename\">Your log file </a></big></b>";
248: print "\n";
249: #link tooriginal LaTeX file (included according Michael Hamlin desire)
1.69 matthew 250: my $tex_temporary_file=IO::File->new($texfile) || die "Couldn't open tex file $texfile for reading: $!\n";
1.35 sakharuk 251: my @tex_content_of_file = <$tex_temporary_file>;
252: close $tex_temporary_file;
253: my $body_tex_file = join(' ',@tex_content_of_file);
254: $texfile =~ s/\.tex$/aaaaa\.html/;
255: $tex_temporary_file = IO::File->new('>'.$texfile);
256: print $tex_temporary_file '<html><head><title>LOGFILE</title></head><body><pre>'.$body_tex_file.'</pre></body></html>'."\n";
257: print "<br /><br />";
258: print "<b><big>The link to ";
259: $texfile=~s/\/home\/httpd//;
260: print "<a href=\"$texfile\">Your original LaTeX file </a></big></b>";
261: print "\n";
1.36 sakharuk 262: }
1.35 sakharuk 263:
1.29 sakharuk 264: } elsif ($body_log_file=~m/<inserted text>/) {
265: my $whereitbegins = index $body_log_file,'<inserted text>';
1.59 albertel 266: print "You are running LaTeX in <b>batch mode</b>.";
1.30 sakharuk 267: while ($whereitbegins != -1) {
268: my $tempobegin=$whereitbegins;
269: $whereitbegins = rindex $body_log_file,'STAMPOFPASSEDRESOURCESTART',$whereitbegins;
270: my $whereitends = index $body_log_file,'STAMPOFPASSEDRESOURCEEND',$whereitbegins;
1.34 sakharuk 271: print "<br />It has found an error in".substr($body_log_file,$whereitbegins+26,$whereitends-$whereitbegins-26)." <br /> and corrected it.\n";
1.30 sakharuk 272: print "Usually this correction is valid but you probably need to check the indicated resource one more time and implement neccessary corrections by yourself.\n";
273: $whereitbegins = index $body_log_file,'<inserted text>',$tempobegin+10;
274: }
1.29 sakharuk 275: $name_file =~ s/\.tex/\.dvi/;
276: my $new_name_file = $name_file;
277: $new_name_file =~ s/\.dvi/\.ps/;
1.67 sakharuk 278: my $papera=$paper;
1.62 sakharuk 279: if ($papera eq 'letter') {$papera='';}
280: if ($papera ne '') {$papera='-t'.$papera;}
281: my $comma = "dvips $papera -Ppdf -G0 -o $new_name_file";
1.59 albertel 282: &busy_wait_command("$comma $name_file 1>/dev/null 2>/dev/null",
283: "for $status_statement now Converting to PS",
284: \%prog_state,$new_name_file);
1.29 sakharuk 285: if (-e $new_name_file) {
286: print "<h1>PDF output file (see link below)</h1>\n";
287: $new_name_file =~ m/^(.*)\./;
1.59 albertel 288: my $ps_file = my $tempo_file = $1.'temporar.ps';
289: my $pdf_file = $1.'.pdf';
1.29 sakharuk 290: if ($laystyle eq 'album' and $numberofcolumns eq '2') {
291: $comma = "psnup -2 -s1.0 $new_name_file";
1.59 albertel 292: &busy_wait_command("$comma $tempo_file 1>/dev/null 2>/dev/null",
293: "for $status_statement now Modifying PS layout",
294: \%prog_state,$tempo_file);
1.29 sakharuk 295: } elsif ($laystyle eq 'book' and $numberofcolumns eq '2') {
1.67 sakharuk 296: my $papera=$paper;
297: if ($papera eq 'letter') {$papera='';}
1.62 sakharuk 298: if ($papera ne '') {$papera='-p'.$papera;}
299: $comma = 'pstops '.$papera.' "2:0+1(0.48w,0)"';
1.63 sakharuk 300: &busy_wait_command("$comma $new_name_file $tempo_file 1>/dev/null 2>/dev/null",
301: "for $status_statement now Modifying PS layout",
302: \%prog_state,$tempo_file);
303:
1.29 sakharuk 304: } else {
1.59 albertel 305: $ps_file=$new_name_file;
1.29 sakharuk 306: }
1.59 albertel 307: &busy_wait_command("ps2pdf $ps_file $pdf_file 1>/dev/null 2>/dev/null",
308: "for $status_statement now Converting PS to PDF",
309: \%prog_state, $pdf_file);
310:
1.29 sakharuk 311: my $texlog = $texfile;
312: my $texaux = $texfile;
313: my $texdvi = $texfile;
314: my $texps = $texfile;
315: $texlog =~ s/\.tex/\.log/;
316: $texaux =~ s/\.tex/\.aux/;
317: $texdvi =~ s/\.tex/\.dvi/;
318: $texps =~ s/\.tex/\.ps/;
1.30 sakharuk 319: my @garb = ($texaux,$texdvi,$texps);
1.29 sakharuk 320: # unlink @garb;
321: unlink $duefile;
1.59 albertel 322: print "<a href=\"/prtspool/$pdf_file\">Your PDF document</a>";
1.36 sakharuk 323: if ($advans_role) {
324: print "<br /><br />";
325: print "<b><big>The link to ";
326: $logfilename=~s/\/home\/httpd//;
327: print "<a href=\"$logfilename\">Your log file </a></big></b>";
328: print "\n";
329: #link tooriginal LaTeX file (included according Michael Hamlin desire)
1.69 matthew 330: my $tex_temporary_file=IO::File->new($texfile) || die "Couldn't open tex file $texfile for reading: $!\n";
1.36 sakharuk 331: my @tex_content_of_file = <$tex_temporary_file>;
332: close $tex_temporary_file;
333: my $body_tex_file = join(' ',@tex_content_of_file);
334: $texfile =~ s/\.tex$/aaaaa\.html/;
335: $tex_temporary_file = IO::File->new('>'.$texfile);
336: print $tex_temporary_file '<html><head><title>LOGFILE</title></head><body><pre>'.$body_tex_file.'</pre></body></html>'."\n";
337: print "<br /><br />";
338: print "<b><big>The link to ";
339: $texfile=~s/\/home\/httpd//;
340: print "<a href=\"$texfile\">Your original LaTeX file </a></big></b>";
341: print "\n";
342: }
1.29 sakharuk 343: }
344: } else {
345: #LaTeX successfully parsed tex file
346: $name_file =~ s/\.tex/\.dvi/;
347: my $new_name_file = $name_file;
348: $new_name_file =~ s/\.dvi/\.ps/;
1.67 sakharuk 349: my $papera=$paper;
1.62 sakharuk 350: if ($papera eq 'letter') {$papera='';}
351: if ($papera ne '') {$papera='-t'.$papera;}
352: my $comma = "dvips $papera -Ppdf -G0 -o $new_name_file";
1.59 albertel 353: &busy_wait_command("$comma $name_file 1>/dev/null 2>/dev/null",
354: "for $status_statement now Converting to PS",
355: \%prog_state,$new_name_file);
1.29 sakharuk 356: if (-e $new_name_file) {
1.61 albertel 357: print "<br />";
1.29 sakharuk 358: $new_name_file =~ m/^(.*)\./;
1.59 albertel 359: my $ps_file = my $tempo_file = $1.'temporar.ps';
360: my $pdf_file = $1.'.pdf';
1.29 sakharuk 361: if ($laystyle eq 'album' and $numberofcolumns eq '2') {
362: $comma = "psnup -2 -s1.0 $new_name_file";
1.59 albertel 363: &busy_wait_command("$comma $tempo_file 1>/dev/null 2>/dev/null",
364: "for $status_statement now Modifying PS layout",
365: \%prog_state,$tempo_file);
1.29 sakharuk 366: } elsif ($laystyle eq 'book' and $numberofcolumns eq '2') {
1.65 sakharuk 367: $papera=~s/t/p/;
368: $comma = 'pstops '.$papera.' "2:0+1(0.48w,0)"';
1.59 albertel 369: &busy_wait_command("$comma $new_name_file $tempo_file 1>/dev/null 2>/dev/null",
370: "for $status_statement now Modifying PS layout",
371: \%prog_state,$tempo_file);
1.29 sakharuk 372: } else {
1.59 albertel 373: $ps_file=$new_name_file;
374: }
1.67 sakharuk 375: my $addtoPSfile={'legal'=>'<< /PageSize [612 1008] >> setpagedevice',
376: 'tabloid'=>'<< /PageSize [792 1224] >> setpagedevice',
377: 'executive'=>,'<< /PageSize [540 720] >> setpagedevice',
378: 'a2'=>'<< /PageSize [1195.02 1690.09] >> setpagedevice',
379: 'a3'=>'<< /PageSize [842 1195.02] >> setpagedevice',
380: 'a4'=>'<< /PageSize [595.2 842] >> setpagedevice',
381: 'a5'=>'<< /PageSize [421.1 595.2] >> setpagedevice',
382: 'a6'=>'<< /PageSize [298.75 421.1] >> setpagedevice',
383: };
384: if ($paper ne 'letter') {
1.69 matthew 385: open(FFH,'<',$ps_file) || die "Couldn't open ps file $ps_file for reading: $!\n";
1.63 sakharuk 386: my $new_ps_file='new'.$ps_file;
1.69 matthew 387: open(FFHS,'>',$new_ps_file) || die "Couldn't open new ps file $new_ps_file for reading: $!\n";
1.67 sakharuk 388: print FFHS $addtoPSfile->{$paper}."\n";
1.63 sakharuk 389: while (<FFH>) {
390: print FFHS $_;
391: }
1.62 sakharuk 392: close(FFH);
1.63 sakharuk 393: close(FFHS);
394: $ps_file=$new_ps_file;
1.62 sakharuk 395: }
1.59 albertel 396: &busy_wait_command("ps2pdf $ps_file $pdf_file 1>/dev/null 2>/dev/null",
397: "for $status_statement now Converting PS to PDF",
398: \%prog_state,$pdf_file);
399:
1.29 sakharuk 400: my $texlog = $texfile;
401: my $texaux = $texfile;
402: my $texdvi = $texfile;
403: my $texps = $texfile;
404: $texlog =~ s/\.tex/\.log/;
405: $texaux =~ s/\.tex/\.aux/;
406: $texdvi =~ s/\.tex/\.dvi/;
407: $texps =~ s/\.tex/\.ps/;
408: my @garb = ($texlog,$texaux,$texdvi,$texps);
1.22 sakharuk 409: # unlink @garb;
1.29 sakharuk 410: unlink $duefile;
1.68 sakharuk 411: print "<a href=\"/prtspool/$pdf_file\">$link_text - click here to download pdf</a>";
1.29 sakharuk 412: print "\n";
413: }
1.63 sakharuk 414: }
1.29 sakharuk 415: } else {
416: print "LaTeX file $texfile was not created successfully";
1.14 sakharuk 417: }
1.43 sakharuk 418: }
1.45 sakharuk 419: print "<br />";
1.44 sakharuk 420: if ($number_of_files>1) {
1.45 sakharuk 421: my $zipfile=$texfile[0];
422: $zipfile=~s/\.tex/\.zip/;
423: my $statement="zip $zipfile";
1.44 sakharuk 424: foreach my $file (@texfile) {
1.45 sakharuk 425: $file=~s/\.tex/.\pdf/;
426: $statement.=' '.$file;
1.44 sakharuk 427: }
1.49 albertel 428: print("<pre>Zip Output:\n");
429: system($statement);
430: print("</pre>");
1.45 sakharuk 431: $zipfile=~s/\/home\/httpd//;
1.49 albertel 432: print "<br /> A <a href=\"$zipfile\">ZIP file</a> of all the PDFs.";
1.44 sakharuk 433: }
1.49 albertel 434: if ($adv) { &Apache::lonhtmlcommon::Close_PrgWin('',\%prog_state); }
1.1 sakharuk 435:
1.59 albertel 436: my $done;
437: sub REAPER {
438: $done=1;
439: }
440:
441: sub busy_wait_command {
442: my ($command,$message,$progress_win,$output_file)=@_;
443:
444: $SIG{CHLD} = \&REAPER;
445: $done=0;
446: my $pid=open(CMD,"$command |");
1.60 albertel 447: if ($adv) {
448: &Apache::lonhtmlcommon::Update_PrgWin('',$progress_win,$message);
449: }
1.59 albertel 450: while(!$done) {
451: sleep 1;
452: my $extra_msg;
453: if ($output_file) {
454: my $size=(stat($output_file))[7];
455: $extra_msg=", $size bytes generated";
456: }
1.60 albertel 457: if ($adv) {
458: &Apache::lonhtmlcommon::Update_PrgWin('',$progress_win,
459: $message.$extra_msg);
460: }
1.59 albertel 461: }
462: $SIG{CHLD}='IGNORE';
463: close(CMD);
464: }
1.1 sakharuk 465:
466:
467:
1.4 sakharuk 468:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>