Changeset 2574 for trunk/gsdl/bin/script/gsConvert.pl
- Timestamp:
- 2001-06-19T14:26:54+12:00 (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/bin/script/gsConvert.pl
r2512 r2574 56 56 print STDERR " or text using third-party programs.\n\n"; 57 57 print STDERR " usage: $0 [options] filename\n"; 58 print STDERR " options:\n\t-type\tdoc|pdf|ps \n\t-output\thtml|text\n";58 print STDERR " options:\n\t-type\tdoc|pdf|ps|rtf\n\t-output\thtml|text\n"; 59 59 print STDERR "\t-timeout\t<max cpu seconds>\n"; 60 60 exit(1); … … 70 70 # read command-line arguments 71 71 if (!parsargv::parse(\@ARGV, 72 'type/(doc|pdf|ps )/', \$input_type,72 'type/(doc|pdf|ps|rtf)/', \$input_type, 73 73 'output/(html|text)/', \$output_type, 74 74 'timeout/\d+/0',\$timeout, … … 339 339 340 340 my $wv_conf = &util::filename_cat($ENV{'GSDLHOME'}, "etc", 341 " wv", "wvHtml.xml");341 "packages", "wv", "wvHtml.xml"); 342 342 343 343 my $cmd = ""; … … 377 377 378 378 # Attempt to convert an RTF document to html with rtftohtml 379 #380 # rtf2html isn't distributed with Greenstone because it is not381 # distributed under the GPL. If you know of a better solution,382 # please let me know.383 379 384 380 sub rtf_to_html { 385 381 my ($input_filename, $output_filestem) = @_; 386 382 387 # we'll give up already if using Windows388 return 0 if $ENV{'GSDLOS'} =~ /^windows$/i;389 390 383 # formulate the command 391 my $r_cmd = &util::filename_cat($ENV{'GSDLHOME'}, "packages", "unix",392 "rtf2html", "rtf2html", "rtf2html");393 $r_cmd = "rtf2html" unless (-e "$r_cmd");394 return 0 unless (-e "$r_cmd");395 384 $cmd = ""; 396 385 if ($timeout) {$cmd = "ulimit -t $timeout;";} 397 $cmd .= "$r_cmd"; 398 $cmd .= " \"$input_filename\" > \"$output_filestem.html\" 2>\"$output_filestem.err\""; 386 $cmd .= "rtftohtml"; 387 388 # it automatically uses $output_filestem.html 389 $cmd .= " \"$input_filename\""; 390 391 $cmd .= " 2>\"$output_filestem.err\"" 392 unless $ENV{'GSDLOS'} =~ /^windows$/i; 393 399 394 400 395 # execute the command … … 404 399 } 405 400 401 # this will probably give a warning under windows... 402 &util::rm("$output_filestem.err"); 403 406 404 # Was the conversion successful? 407 405 if (-e "$output_filestem.html") { 408 open(TMP, "$output_filestem.html"); 409 $line = <TMP>; 410 close(TMP); 411 if ($line && $line =~ /DOCTYPE HTML/) { 412 &util::rm("$output_filestem.err"); 413 return 1; 414 } else { 415 # An error of some sort occurred 416 &util::rm("$output_filestem.html"); 417 &util::rm("$output_filestem.err"); 418 } 419 } 406 return 1; 407 } 408 420 409 return 0; 421 410 }
Note:
See TracChangeset
for help on using the changeset viewer.