Changeset 17701


Ignore:
Timestamp:
2008-11-05T15:26:44+13:00 (15 years ago)
Author:
ak19
Message:

Prints a warning if Perl is not on the path (if it can't be found). This may happen if gs2 was checked out from svn (bin install puts perl in bin-windows folder) *and* if Perl is not installed or not on the PATH.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/common-src/src/lib/gdbmclass.cpp

    r17680 r17701  
    2828#include "gsdlunicode.h"
    2929#include "fileutil.h"
    30 
     30#include "stdlib.h"
    3131
    3232
     
    107107    //text_t cmd = "gzip --decompress --to-stdout \"" + txtgz_filename + "\"";
    108108    //cmd += " | txt2db \"" + filename + "\"";
    109    
    110     text_t cmd;
    111 #ifdef __WIN32__
    112     cmd = "perl -S txtgz-to-gdbm.pl \"" + txtgz_filename + "\" \"" + filename + "\"";
    113 #else
    114     cmd = "perl txtgz-to-gdbm.pl \"" + txtgz_filename + "\" \"" + filename + "\"";
    115 #endif
    116    
     109
     110    // Test to make sure Perl is on the path
     111    text_t cmd_test = "perl -v";
     112    int rv_test = gsdl_system(cmd_test, true, cerr);
     113    if (rv_test != 0) {
     114      cerr << "Tried to find Perl. Return exit value of running "
     115           << cmd_test <<": "<< rv_test << ", (expected this to be 0)" << endl;
     116      cerr << "Check that Perl is set in your environment variable PATH." << endl;
     117      cerr << "At present, PATH=" << getenv("PATH") << endl;
     118    }
     119
     120    text_t cmd = "perl -S txtgz-to-gdbm.pl \"" + txtgz_filename + "\" \"" + filename + "\"";
    117121    int rv = gsdl_system(cmd, true, cerr);
    118122    // For some reason, launching this command with gsdl_system() still returns 1
     
    120124    // we succeeded by looking at whether the output database file was created.
    121125    if (rv != 0) {
    122       cerr << "\nWarning, non-zero return value on running command \""
     126      cerr << "Warning, non-zero return value on running command \""
    123127           << cmd << "\": " << rv << endl;
    124128      if (!file_exists(filename)) {
    125         cerr << "Tried to run command \""<<cmd<<"\", but it failed\n";
     129        cerr << "Tried to run command \""<<cmd<<"\", but it failed" << endl;
    126130      }
    127131    }   
Note: See TracChangeset for help on using the changeset viewer.