#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "<body bgcolor=\"#FFFFFF\">\n";
print "<h1>EXAMPLE</h1>\n";
my $texfile = $ENV{'QUERY_STRING'};
 $_ = $texfile;
 m/^(.*)\/([^\/]+)$/; 
my $name_file = $2;
my $path_file = $1.'/';
 chdir $path_file;
 system("latex $name_file 1>/dev/null 2>/dev/null");
 $name_file =~ s/\.tex/\.dvi/;
my $new_name_file = $name_file;
 $new_name_file =~ s/\.dvi/\.ps/;
my $pro_fun = "dvips -o $new_name_file";
 system("$pro_fun $name_file");
my $name_file = $new_name_file;
 $name_file =~ s/\.ps/\.pdf/;
 system("ps2pdf $new_name_file $name_file");


#print "<a href=\"http://bistromath.lite.msu.edu/$name_file\">Your PDF document</a>\n";
print "\n";




#    my $ere;
#    foreach $ere (%ENV) {
#	print(' SS '.$ere.' => '.$ENV{$ere}.' FF '."\n\n");
#    }
 
