Annotation of loncom/interface/printout.pl, revision 1.65
1.1 sakharuk 1: #!/usr/bin/perl
1.37 albertel 2: # CGI-script to run LaTeX, dvips, ps2ps, ps2pdf etc.
3: #
1.65 ! sakharuk 4: # $Id: printout.pl,v 1.64 2004/08/12 17:19:25 sakharuk 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.51 albertel 35: use Apache::loncommon;
36: use Apache::lonlocal;
1.47 sakharuk 37:
1.59 albertel 38: use strict;
1.49 albertel 39: $|=1;
1.46 albertel 40: my %origENV=%ENV;
1.39 sakharuk 41: if (! &LONCAPA::loncgi::check_cookie_and_load_env()) {
42: print <<END;
43: Content-type: text/html
44:
45: <html>
46: <head><title>Bad Cookie</title></head>
47: <body>
1.40 sakharuk 48: Your cookie information is incorrect.
1.39 sakharuk 49: </body>
50: </html>
51: END
52: return;
53: }
1.51 albertel 54: &Apache::lonlocal::get_language_handle();
55: &Apache::loncommon::content_type(undef,'text/html');
56: my $bodytag=&Apache::loncommon::bodytag('Creating PDF','','');
57: print $bodytag;
1.39 sakharuk 58:
1.40 sakharuk 59: my $identifier = $ENV{'QUERY_STRING'};
60: my $texfile = $ENV{'cgi.'.$identifier.'.file'};
61: my $laystyle = $ENV{'cgi.'.$identifier.'.layout'};
62: my $numberofcolumns = $ENV{'cgi.'.$identifier.'.numcol'};
1.62 sakharuk 63: my $paper = $ENV{'cgi.'.$identifier.'.paper'};
1.40 sakharuk 64: my $selectionmade = $ENV{'cgi.'.$identifier.'.selection'};
65: my $tableofcontents = $ENV{'cgi.'.$identifier.'tableofcontents'};
66: my $tableofindex = $ENV{'cgi.'.$identifier.'tableofindex'};
67: my $advans_role = $ENV{'cgi.'.$identifier.'role'};
1.43 sakharuk 68: my $number_of_files = $ENV{'cgi.'.$identifier.'numberoffiles'}+1;
1.44 sakharuk 69: my $student_names = $ENV{'cgi.'.$identifier.'studentnames'};
1.47 sakharuk 70: my $backref = $ENV{'cgi.'.$identifier.'backref'};
1.43 sakharuk 71:
1.62 sakharuk 72:
1.49 albertel 73: my $adv = $ENV{'request.role.adv'};
74:
1.44 sakharuk 75: my @names_pack=();
76: if ($student_names=~/_END_/) {
77: @names_pack=split(/_ENDPERSON_/,$student_names);
78: }
1.46 albertel 79: #got what we needed reset ENV in case it is to big for system
80: %ENV=%origENV;
1.39 sakharuk 81:
1.14 sakharuk 82: my $figfile = $texfile;
83: $figfile =~ s/^([^\.]+printout)[^t]+\.tex/$1\.dat/;
84: my $duefile = $texfile;
85: $duefile =~ s/^([^\.]+printout)[^t]+\.tex/$1\.due/;
86: #do we have figures?
87: if (-e $figfile) {
1.42 albertel 88: my %done_conversion;
1.14 sakharuk 89: my $temporary_file=IO::File->new($figfile) || die "Couldn't open file for reading: $!\n";
90: my @content_of_file = <$temporary_file>;
91: close $temporary_file;
92: my $noteps;
1.49 albertel 93: my %prog_state;
1.59 albertel 94: if ($adv) { %prog_state=&Apache::lonhtmlcommon::Create_PrgWin('','Coverting Images to EPS','Picture Conversion Status',$#content_of_file,'inline','80'); }
95: foreach my $not_eps (@content_of_file) {
1.49 albertel 96: chomp($not_eps);
1.14 sakharuk 97: if ($not_eps ne '') {
1.44 sakharuk 98: my $status_statement='EPS picture for '.$not_eps;
1.41 sakharuk 99: $not_eps=~s|\/\.\/|\/|g;
1.14 sakharuk 100: my $eps_f = $not_eps;
101: $eps_f =~ s/\.[^.]*$/\.eps/i;
1.41 sakharuk 102: if ($eps_f=~/\/home\/([^\/]+)\/public_html\//) {
103: $eps_f=~s/\/home\/([^\/]+)\/public_html/$1/;
104: $eps_f = '/home/httpd/prtspool/'.$eps_f;
1.58 sakharuk 105: } elsif ($eps_f=~/$Apache::lonnet::perlvar{'lonDocRoot'}\/res\//) {
106: $eps_f=~m/$Apache::lonnet::perlvar{'lonDocRoot'}\/res\/(.+)/;
1.41 sakharuk 107: $eps_f = '/home/httpd/prtspool/'.$1;
1.58 sakharuk 108: } elsif ($eps_f=~/$Apache::lonnet::perlvar{'lonUsersDir'}\//) {
1.57 sakharuk 109: $eps_f=~/$Apache::lonnet::perlvar{'lonUsersDir'}\/([^\/]+)\/\w\/\w\/\w\/(.+)/;
1.56 sakharuk 110: $eps_f = '/home/httpd/prtspool/'.$1.'/'.$2;
1.41 sakharuk 111: }
1.38 sakharuk 112: my $path=$eps_f;
1.41 sakharuk 113: $path=~s/\/([^\/]+)\.eps$//;
1.38 sakharuk 114: File::Path::mkpath($path,0,0777);
1.14 sakharuk 115: my $image = Image::Magick->new;
116: $not_eps =~ s/^\s+//;
117: $not_eps =~ s/\s+$//;
1.42 albertel 118: if ( exists($done_conversion{$not_eps})) {
119: next;
120: }
1.49 albertel 121: if ($adv) {
122: my $prettyname=$not_eps;
123: $prettyname=~s|/home/([^/]+)/public_html|/priv/$1|;
1.58 sakharuk 124: $prettyname=~s|$Apache::lonnet::perlvar{'lonDocRoot'}/|/|;
1.49 albertel 125: &Apache::lonhtmlcommon::Update_PrgWin('',\%prog_state,'Converting to EPS '.$prettyname); }
1.42 albertel 126: $done_conversion{$not_eps}=1;
1.59 albertel 127: my $status = $image->Read($not_eps);
1.14 sakharuk 128: if ($status) {print " $status ";}
129: $image->Set(page => '+100+200');
130: $status = $image->Write($eps_f);
131: if ($status) {print " $status ";}
1.20 sakharuk 132: #check is eps exist in prtspool
133: if(not -e $eps_f) {
134: for (my $i=0;$i<10000;$i++) {
135: if (-e $eps_f.'.'.$i) {
136: rename $eps_f.'.'.$i, $eps_f;
137: last;
138: }
139: }
140: }
1.14 sakharuk 141: }
142: }
1.49 albertel 143: if ($adv) { &Apache::lonhtmlcommon::Close_PrgWin('',\%prog_state); }
1.52 albertel 144: unlink($figfile);
1.14 sakharuk 145: }
1.43 sakharuk 146: #print "$texfile\n"; #name of the tex file for debugging only
147: my @texfile=($texfile);
148: if ($number_of_files>1) {
1.49 albertel 149: @texfile=();
150: for (my $i=1;$i<=$number_of_files;$i++) {
1.43 sakharuk 151: my $new_texfile=$texfile;
1.49 albertel 152: $new_texfile=~s/\.tex/_$i\.tex/;
1.43 sakharuk 153: push @texfile,$new_texfile;
154: }
155: }
1.49 albertel 156:
1.44 sakharuk 157: my $ind=-1;
1.49 albertel 158: my %prog_state;
1.61 albertel 159: print "<a href=\"$backref\"><b>Return</b></a> to last resource.<br /><br />";
1.59 albertel 160: if ($adv) { %prog_state=&Apache::lonhtmlcommon::Create_PrgWin('','Print Status','Class Print Status',$number_of_files,'inline','80'); }
1.61 albertel 161: print "<br />";
1.43 sakharuk 162: foreach $texfile (@texfile) {
1.49 albertel 163: my $status_statement='';
164: my $link_text='download PDF';
165: $ind++;
166: my @stud_info=split(/_END_/,$names_pack[$ind]);
167: my @tempo_array=split(/:/,$stud_info[0]);
168: my $name;
169: if ($tempo_array[3]) {
170: $name=$tempo_array[3];
171: } else {
172: $name=$tempo_array[0].'@'.$tempo_array[1];
173: }
1.61 albertel 174: $link_text='<b>'.$name.'</b>';
1.49 albertel 175: $status_statement.=$name;
176: if ($#stud_info>0) {
177: @tempo_array=split(/:/,$stud_info[-1]);
1.48 albertel 178: if ($tempo_array[3]) {
179: $name=$tempo_array[3];
180: } else {
181: $name=$tempo_array[0].'@'.$tempo_array[1];
182: }
1.61 albertel 183: $link_text.=' - <b>'.$name.'</b>';
1.49 albertel 184: $status_statement.=' - '.$name;
185: }
186: if ($adv) { &Apache::lonhtmlcommon::Update_PrgWin('',\%prog_state,'Creating PDF for '.$status_statement); }
1.29 sakharuk 187: if (-e $texfile) {
188: $texfile =~ m/^(.*)\/([^\/]+)$/;
189: my $name_file = $2;
190: my $path_file = $1.'/';
191: chdir $path_file;
1.59 albertel 192: my $dvi_file= $name_file; $dvi_file =~ s/\.tex/\.dvi/;
193: &busy_wait_command("latex $name_file 1>/dev/null 2>/dev/null",
194: "for $status_statement now LaTeXing file",
195: \%prog_state,$dvi_file);
1.40 sakharuk 196: if ($tableofcontents eq 'yes') {
1.63 sakharuk 197: &busy_wait_command("latex $name_file 1>/dev/null 2>/dev/null",
198: "for $status_statement now LaTeXing file for table of contents",
199: \%prog_state,$dvi_file);
1.40 sakharuk 200: } #to create table of contents
1.33 sakharuk 201: my $idxname=$name_file;
202: $idxname=~s/\.tex$/\.idx/;
1.40 sakharuk 203: if ($tableofindex eq 'yes') {
1.63 sakharuk 204: &busy_wait_command("makeindex $idxname",
205: "making index file",
206: \%prog_state,$idxname);
207: &busy_wait_command("latex $name_file 1>/dev/null 2>/dev/null",
208: "for $status_statement now LaTeXing file for index section",
209: \%prog_state,$dvi_file);
1.33 sakharuk 210: } #to create index
1.29 sakharuk 211: #Do we have a latex error in the log file?
212: my $logfilename = $texfile;
213: $logfilename =~ s/\.tex$/\.log/;
214: my $temporary_file=IO::File->new($logfilename) || die "Couldn't open file for reading: $!\n";
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: }
230: print "Here are the error messages in the LaTeX log file</br><br />";
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) {
240: print "$content_of_file[$i]<br />";
241: }
1.36 sakharuk 242: }
243: if ($advans_role) {
1.35 sakharuk 244: print "<b><big>The link to ";
245: $logfilename=~s/\/home\/httpd//;
246: print "<a href=\"$logfilename\">Your log file </a></big></b>";
247: print "\n";
248: #link tooriginal LaTeX file (included according Michael Hamlin desire)
249: my $tex_temporary_file=IO::File->new($texfile) || die "Couldn't open file for reading: $!\n";
250: my @tex_content_of_file = <$tex_temporary_file>;
251: close $tex_temporary_file;
252: my $body_tex_file = join(' ',@tex_content_of_file);
253: $texfile =~ s/\.tex$/aaaaa\.html/;
254: $tex_temporary_file = IO::File->new('>'.$texfile);
255: print $tex_temporary_file '<html><head><title>LOGFILE</title></head><body><pre>'.$body_tex_file.'</pre></body></html>'."\n";
256: print "<br /><br />";
257: print "<b><big>The link to ";
258: $texfile=~s/\/home\/httpd//;
259: print "<a href=\"$texfile\">Your original LaTeX file </a></big></b>";
260: print "\n";
1.36 sakharuk 261: }
1.35 sakharuk 262:
1.29 sakharuk 263: } elsif ($body_log_file=~m/<inserted text>/) {
264: my $whereitbegins = index $body_log_file,'<inserted text>';
1.59 albertel 265: print "You are running LaTeX in <b>batch mode</b>.";
1.30 sakharuk 266: while ($whereitbegins != -1) {
267: my $tempobegin=$whereitbegins;
268: $whereitbegins = rindex $body_log_file,'STAMPOFPASSEDRESOURCESTART',$whereitbegins;
269: my $whereitends = index $body_log_file,'STAMPOFPASSEDRESOURCEEND',$whereitbegins;
1.34 sakharuk 270: 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 271: 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";
272: $whereitbegins = index $body_log_file,'<inserted text>',$tempobegin+10;
273: }
1.29 sakharuk 274: $name_file =~ s/\.tex/\.dvi/;
275: my $new_name_file = $name_file;
276: $new_name_file =~ s/\.dvi/\.ps/;
1.62 sakharuk 277: my @papers=('letter','legal','tabloid','executive','','a3','a4','a5','');
278: my $papera=$papers[$paper];
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.62 sakharuk 296: my @papers=('letter','legal','tabloid','executive','','a3','a4','a5','');
297: my $papera=$papers[$paper];
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)
330: my $tex_temporary_file=IO::File->new($texfile) || die "Couldn't open file for reading: $!\n";
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.62 sakharuk 349: my @papers=('letter','legal','tabloid','executive','','a3','a4','a5','');
350: my $papera=$papers[$paper];
351: if ($papera eq 'letter') {$papera='';}
352: if ($papera ne '') {$papera='-t'.$papera;}
353: my $comma = "dvips $papera -Ppdf -G0 -o $new_name_file";
1.59 albertel 354: &busy_wait_command("$comma $name_file 1>/dev/null 2>/dev/null",
355: "for $status_statement now Converting to PS",
356: \%prog_state,$new_name_file);
1.29 sakharuk 357: if (-e $new_name_file) {
1.61 albertel 358: print "<br />";
1.29 sakharuk 359: $new_name_file =~ m/^(.*)\./;
1.59 albertel 360: my $ps_file = my $tempo_file = $1.'temporar.ps';
361: my $pdf_file = $1.'.pdf';
1.29 sakharuk 362: if ($laystyle eq 'album' and $numberofcolumns eq '2') {
363: $comma = "psnup -2 -s1.0 $new_name_file";
1.59 albertel 364: &busy_wait_command("$comma $tempo_file 1>/dev/null 2>/dev/null",
365: "for $status_statement now Modifying PS layout",
366: \%prog_state,$tempo_file);
1.29 sakharuk 367: } elsif ($laystyle eq 'book' and $numberofcolumns eq '2') {
1.65 ! sakharuk 368: $papera=~s/t/p/;
! 369: $comma = 'pstops '.$papera.' "2:0+1(0.48w,0)"';
1.59 albertel 370: &busy_wait_command("$comma $new_name_file $tempo_file 1>/dev/null 2>/dev/null",
371: "for $status_statement now Modifying PS layout",
372: \%prog_state,$tempo_file);
1.29 sakharuk 373: } else {
1.59 albertel 374: $ps_file=$new_name_file;
375: }
1.64 sakharuk 376: if (($paper eq '6') or ($paper eq '1') or ($paper eq '2') or ($paper eq '3')
377: or ($paper eq '4') or ($paper eq '5') or ($paper eq '7') or ($paper eq '8')) {
1.62 sakharuk 378: open(FFH,'<',$ps_file) || die "Couldn't open file for reading: $!\n";
1.63 sakharuk 379: my $new_ps_file='new'.$ps_file;
380: open(FFHS,'>',$new_ps_file) || die "Couldn't open file for reading: $!\n";
381: my $i=-1;
382: while (<FFH>) {
383: $i++;
1.64 sakharuk 384: if ($i==0) {
385: if ($paper eq '6') {print FFHS '<< /PageSize [595.2 842] >> setpagedevice'."\n";}
386: if ($paper eq '1') {print FFHS '<< /PageSize [612 1008] >> setpagedevice'."\n";}
387: if ($paper eq '2') {print FFHS '<< /PageSize [794.97 1228.59] >> setpagedevice'."\n";}
388: if ($paper eq '3') {print FFHS '<< /PageSize [542 722.7] >> setpagedevice'."\n";}
389: if ($paper eq '4') {print FFHS '<< /PageSize [1195.02 1690.09] >> setpagedevice'."\n";}
390: if ($paper eq '5') {print FFHS '<< /PageSize [842 1195.02] >> setpagedevice'."\n";}
391: if ($paper eq '7') {print FFHS '<< /PageSize [421.1 595.2] >> setpagedevice'."\n";}
392: if ($paper eq '8') {print FFHS '<< /PageSize [298.75 421.1] >> setpagedevice'."\n";}
393: }
1.63 sakharuk 394: print FFHS $_;
395: }
1.62 sakharuk 396: close(FFH);
1.63 sakharuk 397: close(FFHS);
398: $ps_file=$new_ps_file;
1.62 sakharuk 399: }
1.59 albertel 400: &busy_wait_command("ps2pdf $ps_file $pdf_file 1>/dev/null 2>/dev/null",
401: "for $status_statement now Converting PS to PDF",
402: \%prog_state,$pdf_file);
403:
1.29 sakharuk 404: my $texlog = $texfile;
405: my $texaux = $texfile;
406: my $texdvi = $texfile;
407: my $texps = $texfile;
408: $texlog =~ s/\.tex/\.log/;
409: $texaux =~ s/\.tex/\.aux/;
410: $texdvi =~ s/\.tex/\.dvi/;
411: $texps =~ s/\.tex/\.ps/;
412: my @garb = ($texlog,$texaux,$texdvi,$texps);
1.22 sakharuk 413: # unlink @garb;
1.29 sakharuk 414: unlink $duefile;
1.59 albertel 415: print "<a href=\"/prtspool/$pdf_file\">$link_text</a>";
1.29 sakharuk 416: print "\n";
417: }
1.63 sakharuk 418: }
1.29 sakharuk 419: } else {
420: print "LaTeX file $texfile was not created successfully";
1.14 sakharuk 421: }
1.43 sakharuk 422: }
1.45 sakharuk 423: print "<br />";
1.44 sakharuk 424: if ($number_of_files>1) {
1.45 sakharuk 425: my $zipfile=$texfile[0];
426: $zipfile=~s/\.tex/\.zip/;
427: my $statement="zip $zipfile";
1.44 sakharuk 428: foreach my $file (@texfile) {
1.45 sakharuk 429: $file=~s/\.tex/.\pdf/;
430: $statement.=' '.$file;
1.44 sakharuk 431: }
1.49 albertel 432: print("<pre>Zip Output:\n");
433: system($statement);
434: print("</pre>");
1.45 sakharuk 435: $zipfile=~s/\/home\/httpd//;
1.49 albertel 436: print "<br /> A <a href=\"$zipfile\">ZIP file</a> of all the PDFs.";
1.44 sakharuk 437: }
1.49 albertel 438: if ($adv) { &Apache::lonhtmlcommon::Close_PrgWin('',\%prog_state); }
1.1 sakharuk 439:
1.59 albertel 440: my $done;
441: sub REAPER {
442: $done=1;
443: }
444:
445: sub busy_wait_command {
446: my ($command,$message,$progress_win,$output_file)=@_;
447:
448: $SIG{CHLD} = \&REAPER;
449: $done=0;
450: my $pid=open(CMD,"$command |");
1.60 albertel 451: if ($adv) {
452: &Apache::lonhtmlcommon::Update_PrgWin('',$progress_win,$message);
453: }
1.59 albertel 454: while(!$done) {
455: sleep 1;
456: my $extra_msg;
457: if ($output_file) {
458: my $size=(stat($output_file))[7];
459: $extra_msg=", $size bytes generated";
460: }
1.60 albertel 461: if ($adv) {
462: &Apache::lonhtmlcommon::Update_PrgWin('',$progress_win,
463: $message.$extra_msg);
464: }
1.59 albertel 465: }
466: $SIG{CHLD}='IGNORE';
467: close(CMD);
468: }
1.1 sakharuk 469:
470:
471:
1.4 sakharuk 472:
FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>