Ignore:
Timestamp:
2001-07-18T11:55:26+12:00 (23 years ago)
Author:
jrm21
Message:

replaced some of the -e (exist) tests with -s (size>0) tests when
determining if any output was created, as the shell creates the file when
" > xxx.html" is part of the command.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/bin/script/gsConvert.pl

    r2600 r2656  
    358358    # Was the conversion successful?
    359359
    360     if (-e "$output_filestem.html") {
     360    if (-s "$output_filestem.html") {
    361361    open(TMP, "$output_filestem.html");
    362362    $line = <TMP>;
     
    367367    } else {
    368368        # An error of some sort occurred
    369         &util::rm("$output_filestem.html");
     369        &util::rm("$output_filestem.html") if -e "$output_filestem.html";
    370370        &util::rm("$output_filestem.err") if -e "$output_filestem.err";
    371371    }
     
    396396    if (system($cmd)!=0)
    397397    {
    398     print STDERR "Error executing rtf converter: $!. Continuing...\n";
     398    print STDERR "Error executing rtf converter: $!.\n";
     399    # don't currently bother printing out error log...
     400    # keep going, in case it still created an HTML file...
    399401    }
    400402
     
    402404
    403405    # Was the conversion successful?
    404     if (-e "$output_filestem.html") {
     406    if (-s "$output_filestem.html") {
    405407    return 1;
    406408    }
     409
     410    &util::rm("$output_filestem.html") if (-e "$output_filestem.html");
    407411
    408412    return 0;
     
    421425    $!=0;
    422426
    423     if (system($cmd)!=0)
     427    my $retval=system($cmd);
     428    if ($retval!=0)
    424429    {
    425430    print STDERR "Error executing $cmd";
    426431    if ($!) {print STDERR ": $!";}
    427432    print STDERR "\n";
    428     return 0;
    429433    }
    430434
    431435    # make sure the converter made something
    432     if (! -e "$output_filestem.html")
     436    if ($retval!=0 || ! -s "$output_filestem.html")
    433437    {
    434438    &util::rm("$output_filestem.out") if (-e "$output_filestem.out");
    435     # print out the converters std err, if any
    436     if (-e "$output_filestem.err") {
     439    # print out the converter's std err, if any
     440    if (-s "$output_filestem.err") {
    437441        open (ERRLOG, "$output_filestem.err") || die "$!";
    438442        print STDERR "pdftohtml:\n";
     
    442446        close ERRLOG;
    443447    }
     448    &util::rm("$output_filestem.html") if (-e "$output_filestem.html");
     449    &util::rm("$output_filestem.err") if (-e "$output_filestem.err");
    444450    return 0;
    445451    }
    446452
     453    &util::rm("$output_filestem.err") if (-e "$output_filestem.err");
    447454    &util::rm("$output_filestem.out") if (-e "$output_filestem.out");
    448455    return 1;
     
    466473
    467474    # make sure the converter made something
    468     if (! -e "$output_filestem.text")
    469     {
    470     &util::rm("$output_filestem.out") if (-e "$output_filestem.out");
     475    if (! -s "$output_filestem.text")
     476    {
    471477    # print out the converters std err, if any
    472     if (-e "$output_filestem.err") {
     478    if (-s "$output_filestem.err") {
    473479        open (ERRLOG, "$output_filestem.err") || die "$!";
    474480        print STDERR "pdftotext:\n";
     
    478484        close ERRLOG;
    479485    }
     486    # does this converter create a .out file?
     487    &util::rm("$output_filestem.out") if (-e "$output_filestem.out");
     488    &util::rm("$output_filestem.text") if (-e "$output_filestem.text");
     489    &util::rm("$output_filestem.err") if (-e "$output_filestem.err");
     490
    480491    return 0;
    481492    }
    482 
    483493    &util::rm("$output_filestem.err") if (-e "$output_filestem.err");
    484494    return 1;
Note: See TracChangeset for help on using the changeset viewer.