Changeset 24362


Ignore:
Timestamp:
2011-08-03T21:17:30+12:00 (13 years ago)
Author:
ak19
Message:

The method of locating perl has changed once more: util now defines the fuction get_perl_exec which is used by other scripts to obtain the path to the perl executable they should use.

Location:
main/trunk/greenstone2
Files:
19 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/bin/script/build

    r24192 r24362  
    4343use FileHandle;
    4444use File::Copy;
    45 use Config; # for getting the perlpath in the recommended way
    4645
    4746BEGIN {
     
    277276        #       option was given to build)
    278277
    279         #Config{perlpath}, like $^X, is a special variable containing the full path to the current perl executable we are in
    280         my $download_cmd = "\"$Config{perlpath}\" -S gsWget.pl -P \"$importdir\" -np -nv";
     278        my $download_cmd = "\"".&util::get_perl_exec()."\" -S gsWget.pl -P \"$importdir\" -np -nv";
    281279        $download_cmd .= " -r -N -l inf -R \"*\\?*\"";
    282280        $download_cmd .= " -o \"$outfile.download\"" if $use_out;
     
    328326            # copy download_dir and all it contains to the import directory
    329327            #Config{perlpath}, like $^X, is a special variable containing the full path to the current perl executable we are in
    330             my $download_cmd = "\"$Config{perlpath}\" -S filecopy.pl";
     328            my $download_cmd = "\"".&util::get_perl_exec()."\" -S filecopy.pl";
    331329            $download_cmd .= " -collectdir \"$collectdir\"" if $collectdir =~ /\w/;
    332330            $download_cmd .= " -site \"$site\"" if $site =~ /\w/;
     
    468466
    469467    #Config{perlpath}, like $^X, is a special variable containing the full path to the current perl executable we are in
    470     my $import_cmd = "\"$Config{perlpath}\" -S import.pl";
     468    my $import_cmd = "\"".&util::get_perl_exec()."\" -S import.pl";
    471469    $import_cmd .= " -out \"$outfile.import\"" if $use_out;
    472470    if ($append) {
     
    515513
    516514    #Config{perlpath}, like $^X, is a special variable containing the full path to the current perl executable we are in
    517     my $build_cmd = "\"$Config{perlpath}\" -S buildcol.pl";
     515    my $build_cmd = "\"".&util::get_perl_exec()."\" -S buildcol.pl";
    518516
    519517    my $removeold = 1;
  • main/trunk/greenstone2/bin/script/full-buildcol.pl

    r24192 r24362  
    3232BEGIN {
    3333    die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'};
     34    unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
    3435}
    3536
    3637use strict;
    37 use Config; # for getting the perlpath in the recommended way
     38use util;
    3839
    3940my $quoted_argv = join(" ", map { "\"$_\"" } @ARGV);
    4041
    41 
    42 my $buildcol_cmd = "buildcol.pl -removeold $quoted_argv";
    43 if($ENV{'PERLPATH'}) {
    44     # need to ensure that the path to perl is quoted (in case there's spaces in it)
    45     if($ENV{'GSDLOS'} =~ m/windows/) {
    46     $buildcol_cmd = "\"$ENV{'PERLPATH'}\\Perl.exe\" -S $buildcol_cmd";
    47     } else {
    48     $buildcol_cmd = "\"$ENV{'PERLPATH'}/perl\" -S $buildcol_cmd";
    49     }
    50 } else {
    51     #Config{perlpath}, like $^X, is a special variable containing the full path to the current perl executable we are in
    52     $buildcol_cmd = "\"$Config{perlpath}\" -S $buildcol_cmd";
    53 }
     42my $buildcol_cmd = "\"".&util::get_perl_exec()."\" -S buildcol.pl -removeold $quoted_argv";
    5443
    5544my $buildcol_status = system($buildcol_cmd)/256;
  • main/trunk/greenstone2/bin/script/full-import.pl

    r24192 r24362  
    3333BEGIN {
    3434    die "GSDLOS not set\n" unless defined $ENV{'GSDLOS'};
     35    unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
    3536}
    3637
    3738use strict;
    38 use Config; # for getting the perlpath in the recommended way
     39use util;
    3940
    4041my $quoted_argv = join(" ", map { "\"$_\"" } @ARGV);
    4142
    42 my $import_cmd = "import.pl -removeold $quoted_argv";
    43 if($ENV{'PERLPATH'}) {
    44     # need to ensure that the path to perl is quoted (in case there's spaces in it)
    45     if($ENV{'GSDLOS'} =~ m/windows/) {
    46     $import_cmd = "\"$ENV{'PERLPATH'}\\Perl.exe\" -S $import_cmd";
    47     } else {
    48     $import_cmd = "\"$ENV{'PERLPATH'}/perl\" -S $import_cmd";
    49     }
    50 } else {
    51     #Config{perlpath}, like $^X, is a special variable containing the full path to the current perl executable we are in
    52     $import_cmd = "\"$Config{perlpath}\" -S $import_cmd";
    53 }
     43# need to ensure that the path to perl is quoted (in case there's spaces in it)
     44my $import_cmd = "\"".&util::get_perl_exec()."\" -S import.pl -removeold $quoted_argv";   
    5445
    5546my $import_status = system($import_cmd)/256;
  • main/trunk/greenstone2/bin/script/full-rebuild.pl

    r24192 r24362  
    3939}
    4040
    41 
    4241use strict;
    43 
    44 use Config; # for getting the perlpath in the recommended way
    4542use util;
    4643
     
    105102    my $final_status = 0;
    106103
    107     my $launch_cmd = "";
    108     if($ENV{'PERLPATH'}) {
    109104    # need to ensure that the path to perl is quoted (in case there's spaces in it)
    110     if($ENV{'GSDLOS'} =~ m/windows/) {
    111         $launch_cmd = "\"$ENV{'PERLPATH'}\\Perl.exe\" -S ";
    112     } else {
    113         $launch_cmd = "\"$ENV{'PERLPATH'}/perl\" -S ";
    114     }
    115     } else {
    116     #Config{perlpath}, like $^X, is a special variable containing the full path to the current perl executable we are in
    117     $launch_cmd = "\"$Config{perlpath}\" -S ";
    118     }
     105    my $launch_cmd = "\"".&util::get_perl_exec()."\" -S ";   
    119106   
    120107    print "\n";
  • main/trunk/greenstone2/bin/script/gsConvert.pl

    r24223 r24362  
    4747    die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
    4848    unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
    49 
    50     if(!$ENV{'PERLPATH'}) {
    51     use Config; # for some reason, this can't be a require statement
    52     my $full_perl_exec = $Config{perlpath}; #$^X;   
    53     require File::Basename;
    54     my $perl_path = File::Basename::dirname($full_perl_exec);
    55     $ENV{'PERLPATH'} = $perl_path;
    56     }
    57 
    5849}
    5950
     
    6354use util;
    6455use Cwd;
    65 #use Config; # for getting the perlpath in the recommended way
    66 # Note: even though this (and other) use statement comes after its
    67 # usage in BEGIN, the use statement is in fact executed before BEGIN.
    68 # Doesn't work here for Greenstone 3.
    69 
    7056
    7157# Are we running on WinNT or Win2000 (or later)?
     
    419405    # formulate the command
    420406    my $cmd = "";
    421     my $full_perl_path = &util::filename_cat($ENV{'PERLPATH'},"perl");
     407    my $full_perl_path = &util::get_perl_exec();
    422408    $cmd .= "\"$full_perl_path\" -S ppttohtml.pl ";
    423409    $cmd .= " \"$input_filename\" \"$output_filestem.html\"";
     
    453439    # formulate the command
    454440    my $cmd = "";
    455     my $full_perl_path = &util::filename_cat($ENV{'PERLPATH'},"perl");
     441    my $full_perl_path = &util::get_perl_exec();
    456442    $cmd .= "\"$full_perl_path\" -S xlstohtml.pl ";
    457443    $cmd .= " \"$input_filename\" \"$output_filestem.html\"";
     
    10141000    my $cmd = "";
    10151001    if ($timeout) {$cmd = "ulimit -t $timeout;";}
    1016     my $full_perl_path = &util::filename_cat($ENV{'PERLPATH'},"perl");
     1002    my $full_perl_path = &util::get_perl_exec();
    10171003    $cmd .= "\"$full_perl_path\" -S pdftohtml.pl -zoom $pdf_zoom";
    10181004    $cmd .= " -c" if ($pdf_complex);
     
    10891075    if ($timeout) {$cmd = "ulimit -t $timeout;";}
    10901076    $output_type =~ s/.*\_(.*)/$1/i;
    1091     my $full_perl_path = &util::filename_cat($ENV{'PERLPATH'},"perl");
     1077    my $full_perl_path = &util::get_perl_exec();
    10921078    $cmd .= "\"$full_perl_path\" -S pdfpstoimg.pl -convert_to $output_type \"$input_filename\" \"$output_filestem\"";
    10931079    if ($ENV{'GSDLOS'} !~ m/^windows$/i || $is_winnt_2000) {
  • main/trunk/greenstone2/bin/script/gti.pl

    r24223 r24362  
    3131    die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
    3232    unshift (@INC, "$ENV{'GSDLHOME'}/perllib");
    33 
    34     if(!$ENV{'PERLPATH'}) {
    35     use Config; # for getting the perlpath in the recommended way
    36     my $full_perl_exec = $Config{perlpath}; #$^X;
    37     require File::Basename;
    38     my $perl_path = File::Basename::dirname($full_perl_exec);
    39     $ENV{'PERLPATH'} = $perl_path;
    40     }
    4133}
    4234
     
    645637
    646638    my $target_filepath = &util::filename_cat($gsdl_root_directory, $target_file);
    647     my $perl_exec = &util::filename_cat($ENV{'PERLPATH'}, "perl");
     639    my $perl_exec = &util::get_perl_exec();
    648640    my $java_exec = "java";
    649641    if(defined($ENV{'JAVA_HOME'}) && $ENV{'JAVA_HOME'} ne ""){
  • main/trunk/greenstone2/bin/script/incremental-buildcol.pl

    r24192 r24362  
    4242no strict 'subs'; # allow barewords (eg STDERR) as function arguments
    4343
    44 use Config; # for getting the perlpath in the recommended way
    4544use util;
    4645use colcfg;
     
    9291    print STDERR "Unable to use collection \"$collection\" within \"$collect_dir\"\n";
    9392    exit -1;
    94     }   
    95 
     93    }
    9694
    9795    if (!defined $build_dir) {
     
    103101    my $quoted_argv = join(" ", map { "\"$_\"" } @filtered_argv);
    104102   
    105     my $buildcol_cmd = "buildcol.pl";
    106     if($ENV{'PERLPATH'}) {
    107     # need to ensure that the path to perl is quoted (in case there's spaces in it)
    108     if($ENV{'GSDLOS'} =~ m/windows/) { 
    109         $buildcol_cmd = "\"$ENV{'PERLPATH'}\\Perl.exe\" -S $buildcol_cmd";
    110     } else {
    111         $buildcol_cmd = "\"$ENV{'PERLPATH'}/perl\" -S $buildcol_cmd";
    112     }
    113     } else {
    114     #Config{perlpath}, like $^X, is a special variable containing the full path to the current perl executable we are in
    115     $buildcol_cmd = "\"$Config{perlpath}\" -S $buildcol_cmd";
    116     }
     103    my $buildcol_cmd = "\"".&util::get_perl_exec()."\" -S buildcol.pl";
    117104
    118105    # Read in the collection configuration file.
  • main/trunk/greenstone2/bin/script/incremental-import-onlyadd.pl

    r24192 r24362  
    3131
    3232
    33 
    3433BEGIN {
    3534    die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
     
    3837}
    3938
    40 
    4139use strict;
    42 
    43 use Config; # for getting the perlpath in the recommended way
    4440use dbutil;
    4541use util;
     
    6056    exit(-1);
    6157    }
    62 
    6358
    6459    my $collection = pop @argv;
     
    109104    my $quoted_argv = join(" ", map { "\"$_\"" } @filtered_argv);
    110105   
    111 
    112     my $import_cmd = "import.pl";
    113     if($ENV{'PERLPATH'}) {
    114106    # need to ensure that the path to perl is quoted (in case there's spaces in it)
    115     if($ENV{'GSDLOS'} =~ m/windows/) {
    116         $import_cmd = "\"$ENV{'PERLPATH'}\\Perl.exe\" -S $import_cmd";
    117     } else {
    118         $import_cmd = "\"$ENV{'PERLPATH'}/perl\" -S $import_cmd";
    119     }
    120     } else {
    121     #Config{perlpath}, like $^X, is a special variable containing the full path to the current perl executable we are in
    122     $import_cmd = "\"$Config{perlpath}\" -S $import_cmd";
    123     }
     107    my $import_cmd = "\"".&util::get_perl_exec()."\" -S import.pl";
    124108
    125109    if (-e $archiveinf_doc) {
    126     $import_cmd .= " -keepold";
    127    
     110    $import_cmd .= " -keepold";
    128111    }
    129112    else {
     
    135118
    136119    $import_cmd .= " $quoted_argv \"$collection\"";
    137 
    138120   
    139121    my $import_status = system($import_cmd)/256;
  • main/trunk/greenstone2/bin/script/incremental-import.pl

    r24192 r24362  
    3131
    3232
    33 
    3433BEGIN {
    3534    die "GSDLHOME not set\n" unless defined $ENV{'GSDLHOME'};
     
    3837}
    3938
    40 
    4139use strict;
    42 
    43 use Config; # for getting the perlpath in the recommended way
    4440use dbutil;
    4541use util;
     
    6056    exit(-1);
    6157    }
    62 
    6358
    6459    my $collection = pop @argv;
     
    129124    my $quoted_argv = join(" ", map { "\"$_\"" } @filtered_argv);
    130125   
    131 
    132     my $import_cmd = "import.pl";
    133     if($ENV{'PERLPATH'}) {
    134126    # need to ensure that the path to perl is quoted (in case there's spaces in it)
    135     if($ENV{'GSDLOS'} =~ m/windows/) {
    136         $import_cmd = "\"$ENV{'PERLPATH'}\\Perl.exe\" -S $import_cmd";
    137     } else {
    138         $import_cmd = "\"$ENV{'PERLPATH'}/perl\" -S $import_cmd";
    139     }
    140     } else {
    141     #Config{perlpath}, like $^X, is a special variable containing the full path to the current perl executable we are in
    142     $import_cmd = "\"$Config{perlpath}\" -S $import_cmd";
    143     }
     127    my $import_cmd = "\"".&util::get_perl_exec()."\" -S import.pl";
    144128
    145129    if (defined $manifest) {
  • main/trunk/greenstone2/bin/script/incremental-rebuild.pl

    r24192 r24362  
    3939}
    4040
    41 
    4241use strict;
    43 
    44 use Config; # for getting the perlpath in the recommended way
    4542use util;
    4643
     
    8582    my $final_status = 0;
    8683   
    87     my $launch_cmd = "";
    88     if($ENV{'PERLPATH'}) {
    8984    # need to ensure that the path to perl is quoted (in case there's spaces in it)
    90     if($ENV{'GSDLOS'} =~ m/windows/) {
    91         $launch_cmd = "\"$ENV{'PERLPATH'}\\Perl.exe\" -S ";
    92     } else {
    93         $launch_cmd = "\"$ENV{'PERLPATH'}/perl\" -S ";
    94     }
    95     } else {
    96     #Config{perlpath}, like $^X, is a special variable containing the full path to the current perl executable we are in
    97     $launch_cmd = "\"$Config{perlpath}\" -S ";
    98     }
     85    my $launch_cmd = "\"".&util::get_perl_exec()."\" -S ";   
    9986
    10087    print STDERR "\n";
  • main/trunk/greenstone2/bin/script/mirror.pl

    r24192 r24362  
    4848}
    4949
    50 use Config; # for getting the perlpath in the recommended way
    5150use arcinfo;
    5251use colcfg;
     
    117116    # run the mirror program from the import directory
    118117    my  $cmd = "cd $importdir; ";
    119     #Config{perlpath}, like $^X, is a special variable containing the full path to the current perl executable we are in
    120     $cmd .= "\"$Config{perlpath}\" -S gsw3mir.pl -cfgfile $etcdir/w3mir.cfg";
     118    # need to ensure that the path to perl is quoted (in case there's spaces in it)
     119    $cmd .= "\"".&util::get_perl_exec()."\" -S gsw3mir.pl -cfgfile $etcdir/w3mir.cfg";
    121120    # print "\n$cmd\n";
    122121    `$cmd`;
     
    128127    elsif ((-e "$etcdir/wget.cfg") && (-e "$etcdir/wget.url")) {
    129128    $ENV{WGETRC} = "$etcdir/wget.cfg";
    130     my $cmd = "\"$Config{perlpath}\" -S gsWget.pl --input-file=$etcdir/wget.url --directory-prefix=$importdir";
     129    my $cmd = "\"".&util::get_perl_exec()."\" -S gsWget.pl --input-file=$etcdir/wget.url --directory-prefix=$importdir";
    131130    system($cmd);
    132131    }
  • main/trunk/greenstone2/perllib/cgiactions/baseaction.pm

    r24192 r24362  
    2828
    2929use strict;
    30 
     30use util;
    3131use inexport;
    32 use Config; # for getting the perlpath in the recommended way
    3332
    3433our $authenication_enabled = 0;
     
    434433    my $gsdl_cgi = $self->{'gsdl_cgi'};
    435434
    436     my $sendmail_command = "\"$Config{perlpath}\" -S sendmail.pl";
     435    my $sendmail_command = "\"".&util::get_perl_exec()."\" -S sendmail.pl";
    437436    $sendmail_command .= " -to \"" . $mail_to_address . "\"";
    438437    $sendmail_command .= " -from \"" . $mail_from_address . "\"";
     
    463462    $perl_args = "-collectdir \"$collect_dir\" " . $perl_args;
    464463
    465     my $perl_command = "\"$Config{perlpath}\" -S $script $perl_args";
     464    my $perl_command = "\"".&util::get_perl_exec()."\" -S $script $perl_args";
    466465
    467466
  • main/trunk/greenstone2/perllib/cgiactions/buildaction.pm

    r24192 r24362  
    3636
    3737use util;
    38 use Config; # for getting the perlpath in the recommended way
    3938
    4039BEGIN {
     
    139138
    140139    my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
    141     my $cmd = "\"$Config{perlpath}\" -S full-import.pl \"$collect\"";
     140    my $cmd = "\"".&util::get_perl_exec()."\" -S full-import.pl \"$collect\"";
    142141
    143142    my ($status,$report) = $self->run_build_cmd($cmd);
     
    178177
    179178    my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
    180     my $cmd = "\"$Config{perlpath}\" -S full-buildcol.pl \"$collect\"";
     179    my $cmd = "\"".&util::get_perl_exec()."\" -S full-buildcol.pl \"$collect\"";
    181180
    182181    my ($status,$report) = $self->run_build_cmd($cmd);
     
    216215   
    217216    my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
    218     my $cmd = "\"$Config{perlpath}\" -S full-rebuild.pl \"$collect\"";
     217    my $cmd = "\"".&util::get_perl_exec()."\" -S full-rebuild.pl \"$collect\"";
    219218
    220219    my ($status,$report) = $self->run_build_cmd($cmd);
     
    256255
    257256    my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
    258     my $cmd = "\"$Config{perlpath}\" -S incremental-import.pl \"$collect\"";
     257    my $cmd = "\"".&util::get_perl_exec()."\" -S incremental-import.pl \"$collect\"";
    259258
    260259    my ($status,$report) = $self->run_build_cmd($cmd);
     
    295294
    296295    my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
    297     my $cmd = "\"$Config{perlpath}\" -S incremental-buildcol.pl \"$collect\"";
     296    my $cmd = "\"".&util::get_perl_exec()."\" -S incremental-buildcol.pl \"$collect\"";
    298297
    299298    my ($status,$report) = $self->run_build_cmd($cmd);
     
    334333
    335334    my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
    336     my $cmd = "\"$Config{perlpath}\" -S incremental-rebuild.pl \"$collect\"";
     335    my $cmd = "\"".&util::get_perl_exec()."\" -S incremental-rebuild.pl \"$collect\"";
    337336
    338337    my ($status,$report) = $self->run_build_cmd($cmd);
     
    404403       
    405404        ## my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
    406         my $cmd = "\"$Config{perlpath}\" -S incremental-rebuild.pl -manifest \"$manifest_filename\" \"$collect\"";
     405        my $cmd = "\"".&util::get_perl_exec()."\" -S incremental-rebuild.pl -manifest \"$manifest_filename\" \"$collect\"";
    407406
    408407        ($status,$report) = $self->run_build_cmd($cmd);
  • main/trunk/greenstone2/perllib/cgiactions/indexaction.pm

    r24192 r24362  
    2929
    3030use strict;
    31 
     31use util;
    3232use cgiactions::baseaction;
    33 use Config; # for getting the perlpath in the recommended way
    3433
    3534
    3635@indexaction::ISA = ('baseaction');
    37 
    38 
    39 
    40 
    41 
    42 
    4336
    4437# 'a' for action, and 'c' for collection are also compulsorary, and
     
    133126
    134127    my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
    135     my $cmd = "\"$Config{perlpath}\" -S full-import.pl \"$collect\"";
     128    my $cmd = "\"".&util::get_perl_exec()."\" -S full-import.pl \"$collect\"";
    136129
    137130    my ($status,$report) = $self->run_build_cmd($cmd);
     
    172165
    173166    my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
    174     my $cmd = "\"$Config{perlpath}\" -S full-buildcol.pl \"$collect\"";
     167    my $cmd = "\"".&util::get_perl_exec()."\" -S full-buildcol.pl \"$collect\"";
    175168
    176169    my ($status,$report) = $self->run_build_cmd($cmd);
     
    211204
    212205    my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
    213     my $cmd = "\"$Config{perlpath}\" -S full-rebuild.pl \"$collect\"";
     206    my $cmd = "\"".&util::get_perl_exec()."\" -S full-rebuild.pl \"$collect\"";
    214207
    215208    my ($status,$report) = $self->run_build_cmd($cmd);
     
    251244
    252245    my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
    253     my $cmd = "\"$Config{perlpath}\" -S incremental-import.pl \"$collect\"";
     246    my $cmd = "\"".&util::get_perl_exec()."\" -S incremental-import.pl \"$collect\"";
    254247
    255248    my ($status,$report) = $self->run_build_cmd($cmd);
     
    292285
    293286    my $bin_script = &util::filename_cat($gsdl_home,"bin","script");
    294     my $cmd = "\"$Config{perlpath}\" -S incremental-buildcol.pl \"$collect\"";
     287    my $cmd = "\"".&util::get_perl_exec()."\" -S incremental-buildcol.pl \"$collect\"";
    295288
    296289    my ($status,$report) = $self->run_build_cmd($cmd);
     
    329322    $self->lock_collection($username, $collect);
    330323
    331     my $cmd = "\"$Config{perlpath}\" -S incremental-rebuild.pl \"$collect\"";
     324    my $cmd = "\"".&util::get_perl_exec()."\" -S incremental-rebuild.pl \"$collect\"";
    332325
    333326    my ($status,$report) = $self->run_build_cmd($cmd);
  • main/trunk/greenstone2/perllib/g2futil.pm

    r24192 r24362  
    1515use strict;
    1616use util;
    17 use Config; # for getting the perlpath in the recommended way
    1817
    1918sub run_cmd_old
     
    3130   
    3231    if ($verbosity >= 2) {
    33     print "Runing command:\n";
     32    print "Running command:\n";
    3433    print "$cmd\n";
    3534    }
     
    6463    }
    6564    if (($prog =~ m/.pl$/i) && ($ENV{'GSDLOS'} =~ m/^windows/)) {
    66     $prog ="\"$Config{perlpath}\" -S $prog";
     65    $prog ="\"".&util::get_perl_exec()."\" -S $prog";
    6766    }
    6867 
  • main/trunk/greenstone2/perllib/lucenebuilder.pm

    r24192 r24362  
    4444use strict;
    4545no strict 'refs';
    46 use Config; # for getting the perlpath in the recommended way
     46use util;
    4747
    4848sub BEGIN {
     
    8282    else
    8383    {
    84     $self->{'full_lucene_passes_exe'} = "\"$Config{perlpath}\" -S \"$lucene_passes_script\"";
     84    $self->{'full_lucene_passes_exe'} = "\"".&util::get_perl_exec()."\" -S \"$lucene_passes_script\"";
    8585    }
    8686
  • main/trunk/greenstone2/perllib/plugins/ConvertBinaryFile.pm

    r24360 r24362  
    4444no strict 'refs'; # allow filehandles to be variables and viceversa
    4545no strict 'subs';
    46 use Config; # for getting the perlpath in the recommended way
     46use util;
    4747
    4848
     
    279279#    }
    280280
    281     my $cmd = "\"$Config{perlpath}\" -S gsConvert.pl -verbose $verbosity ";
     281    my $cmd = "\"".&util::get_perl_exec()."\" -S gsConvert.pl -verbose $verbosity ";
    282282    if (defined $self->{'convert_options'}) {
    283283    $cmd .= $self->{'convert_options'} . " ";
  • main/trunk/greenstone2/perllib/plugins/ConvertToRogPlugin.pm

    r24225 r24362  
    3131use strict;
    3232no strict 'refs'; # allow filehandles to be variables and viceversa
    33 use Config; # for getting the perlpath in the recommended way
     33use util;
    3434
    3535sub BEGIN {
     
    122122    # making sure the converter gives us the appropriate output type
    123123    my $output_type = lc($convert_to);
    124     my $cmd = "\"$Config{perlpath}\" -S gsMusicConvert.pl -verbose $verbosity -errlog \"$errlog\" -output $output_type \"$tmp_filename\"";
     124    my $cmd = "\"".&util::get_perl_exec()."\" -S gsMusicConvert.pl -verbose $verbosity -errlog \"$errlog\" -output $output_type \"$tmp_filename\"";
    125125    $output_type = `$cmd`;
    126126
  • main/trunk/greenstone2/perllib/util.pm

    r24291 r24362  
    3131use File::Copy;
    3232use File::Basename;
     33# Config for getting the perlpath in the recommended way, though it uses paths that are
     34# hard-coded into the Config file that's generated upon configuring and compiling perl.
     35# $^X works better in some cases to return the path to perl used to launch the script,
     36# but if launched with plain "perl" (no full-path), that will be just what it returns.
     37use Config;
    3338
    3439# removes files (but not directories)
     
    16041609}
    16051610
     1611sub get_perl_exec() {   
     1612    my $perl_exec = $^X; # may return just "perl"
     1613   
     1614    if($ENV{'PERLPATH'}) {
     1615        # OR: # $perl_exec = &util::filename_cat($ENV{'PERLPATH'},"perl");
     1616        if($ENV{'GSDLOS'} =~ m/windows/) {
     1617            $perl_exec = "$ENV{'PERLPATH'}\\Perl.exe";
     1618        } else {
     1619            $perl_exec = "$ENV{'PERLPATH'}/perl";
     1620        }
     1621    } else { # no PERLPATH, use Config{perlpath} else $^X: special variables
     1622        # containing the full path to the current perl executable we're using
     1623        $perl_exec = $Config{perlpath}; # configured path for perl
     1624        if (!-e $perl_exec) { # may not point to location on this machine
     1625            $perl_exec = $^X; # may return just "perl"
     1626            if($perl_exec =~ m/^perl/i) { # warn if just perl or Perl.exe
     1627                print STDERR "**** WARNING: Perl exec found contains no path: $perl_exec";             
     1628            }
     1629        }
     1630    }
     1631   
     1632    return $perl_exec;
     1633}
     1634
     1635
    160616361;
Note: See TracChangeset for help on using the changeset viewer.