Changeset 35174


Ignore:
Timestamp:
2021-05-20T15:10:20+12:00 (3 years ago)
Author:
kjdon
Message:

gsConvert.pl now prints out the command it will run, if verbosity > 2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/bin/script/gsConvert.pl

    r32290 r35174  
    6969my $pdf_allow_images_only;
    7070my $windows_scripting;
     71my $verbosity;
    7172my $enc;
    7273
     
    9293    print STDERR "\t\t-pdf_complex is set\n";
    9394    print STDERR "\t-pdf_dpi\tSet the resolution in DPI of background images produced by xpdf's pdftohtml\n";
     95    print STDERR "\t-verbosity\tSet verbosity to 3 to see the commands that are run\n";
    9496    exit(1);
    9597}
     
    9799my $faillogfile="";
    98100my $timeout=0;
    99 my $verbosity=0;
    100101
    101102sub main
    102103{
    103104    my (@ARGV) = @_;
    104     my ($input_type,$output_type,$verbose);
     105    my ($input_type,$output_type);
    105106
    106107    # Dynamically figure out what the --type option can support, based on whether -windows_scripting
     
    126127             'output/(auto|html|text|pagedimg).*/', \$output_type, # regex includes html_multi and (paged_)pretty_html besides html, as well as pagedimgtxt_<imgext> besides pagedimg_<imgext>
    127128             'timeout/\d+/0',\$timeout,
    128              'verbose/\d+/0', \$verbose,
     129             'verbosity/\d+/1', \$verbosity,
    129130             'windows_scripting',\$windows_scripting,
    130131             'use_strings', \$use_strings,
     
    141142    }
    142143
    143     $verbosity=$verbose if defined $verbose;
    144      
    145144    # Make sure the input file exists and can be opened for reading
    146145    if (scalar(@ARGV!=1)) {
     
    454453        if ($ENV{'GSDLOS'} !~ m/^windows$/i || $is_winnt_2000);
    455454
     455        print STDERR "gsConvert.pl: About to run cmd $cmd\n" if $verbosity >2;
    456456        if (system($cmd) !=0) {
    457457        print STDERR "Powerpoint VB Scripting convert failed\n";
     
    472472
    473473    # execute the command
     474    print STDERR "gsConvert.pl: About to run cmd $cmd\n" if $verbosity >2;
    474475    $!=0;
    475476    if (system($cmd)!=0)
     
    507508   
    508509    # execute the command
     510    print STDERR "gsConvert.pl: About to run cmd $cmd\n" if $verbosity >2;
     511
    509512    $!=0;
    510513    if (system($cmd)!=0)
     
    586589
    587590#    print STDERR "***** wvware launch cmd = $launch_cmd\n";
     591    print STDERR "gsConvert.pl: About to run cmd $launch_cmd\n" if $verbosity >2;
    588592
    589593    $wvware_status = system($launch_cmd)/256;
     
    636640    $cmd .= " 2> \"$output_filestem.err\""
    637641        if ($ENV {'GSDLOS'} !~ m/^windows$/i || $is_winnt_2000);   
    638     #print STDERR "@@@@@@@@@ cmd=$cmd\n";
    639642   
    640643    # execute the command
     644    print STDERR "gsConvert.pl: About to run cmd $cmd\n" if $verbosity >2;
     645
    641646    $!=0;
    642647    if (system($cmd)!=0)
     
    709714
    710715    # execute the command
     716    print STDERR "gsConvert.pl: About to run cmd $cmd\n" if $verbosity >2;
     717   
    711718    $!=0;
    712719    if (system($cmd)!=0)
     
    831838    }
    832839
     840    print STDERR "gsConvert.pl: About to run cmd $cmd\n" if $verbosity >2;
    833841    $!=0;
    834 
    835842    my $retval=system($cmd);
    836843    if ($retval!=0)
     
    913920    }
    914921
    915     #print STDERR "@@@@ Running command: $cmd\n";
    916 
     922    print STDERR "gsConvert.pl: About to run cmd $cmd\n" if $verbosity >2;
    917923    $!=0;
    918924    my $retval=system($cmd);
     
    974980    my $imagick_cmd = "\"".&util::get_perl_exec()."\" -S gs-magick.pl";
    975981    $imagick_cmd = $imagick_cmd." --verbosity=$verbosity" if defined $verbosity;
     982    print STDERR "gsConvert.pl: About to run cmd $imagick_cmd\n" if $verbosity >2;
    976983    my $result = `$imagick_cmd identify 2>&1`;
    977984
     
    10081015    # with quoting when GSDLHOME might contain spaces) but assume
    10091016    # that the PATH is set up correctly
     1017    print STDERR "gsConvert.pl: About to run cmd $cmd\n" if $verbosity >2;
    10101018    $!=0;
    10111019    my $retval=system($cmd);
     
    10721080    $cmd .= " -nopgbrk";
    10731081    }
    1074     # Avoid the silly solitary carriage returns (CR in Notepad) at the end
    1075     # of lines that ends up as \n appended to the doc title
    1076     # by setting the end of line marker to unix style solitary newline (LF or \n),
    1077     # which doesn't end up in the doc title
    1078     $cmd .= " -eol unix";
     1082    # Avoid the silly solitary carriage returns (CR in Notepad) at the end
     1083    # of lines that ends up as \n appended to the doc title
     1084    # by setting the end of line marker to unix style solitary newline (LF or \n),
     1085    # which doesn't end up in the doc title
     1086    $cmd .= " -eol unix";
    10791087    $cmd .= " \"$input_filename\" \"$output_filestem.text\"";   
    1080 
    1081     print STDERR "@@@@ Running command: $cmd\n";
    1082    
    1083     return _run_pdf_to_text_cmd($cmd, $output_filestem);
     1088   
     1089    return _run_pdf_to_text_cmd($cmd, $output_filestem);
    10841090}
    10851091
     
    10911097    my $cmd = "pdftotext \"$input_filename\" \"$output_filestem.text\"";
    10921098   
    1093     return _run_pdf_to_text_cmd($cmd, $output_filestem);
     1099    return _run_pdf_to_text_cmd($cmd, $output_filestem);
    10941100}
    10951101
    10961102sub _run_pdf_to_text_cmd {
    1097     my ($cmd, $output_filestem) = @_;
     1103    my ($cmd, $output_filestem) = @_;
    10981104
    10991105    if ($ENV{'GSDLOS'} !~ m/^windows$/i) {
     
    11021108    $cmd .= " > \"$output_filestem.err\"";
    11031109    }
    1104    
     1110    print STDERR "gsConvert.pl: About to run cmd $cmd\n" if $verbosity >2;
    11051111    if (system($cmd)!=0)
    11061112    {
     
    11781184    #$cmd .= "pstotext -output \"$output_filestem.text\" $input_filename\"";
    11791185    $cmd .= " 2> $output_filestem.err";
     1186
     1187    print STDERR "gsConvert.pl: About to run cmd $cmd\n" if $verbosity >2;
    11801188    $!=0;
    1181 
    11821189    my $retcode=system($cmd);
    11831190    $retcode = $? >> 8;  # see man perlfunc - system for this...
Note: See TracChangeset for help on using the changeset viewer.