Changeset 9218


Ignore:
Timestamp:
2005-03-01T12:10:22+13:00 (19 years ago)
Author:
kjdon
Message:

made this work under windows without black screens. had to use gsdl_system, but then it didn't seem to like >filename, so I pass the filename as an arg to the perl, and teh perl runs teh java > filename

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/src/colservr/lucenesearch.cpp

    r9210 r9218  
    3737
    3838#include "gsdlconf.h"
     39#include "gsdltools.h"
    3940#include "lucenesearch.h"
    4041#include "fileutil.h"
     
    9495#endif
    9596 
    96   cerr << "**** in luecen search" << endl;
     97  cerr << "**** in lucene search" << endl;
    9798
    9899  char *indexname = (filename_cat(collectdir, getindexsuffix(queryparams))).getcstr();
     
    119120
    120121  text_t cmd = "lucene_query.pl ";
    121   cmd += indexname + (text_t)" \"" + to_utf8(queryparams.querystring) + (text_t)"\"";
     122  cmd += (text_t)" \""+indexname + (text_t)"\" \"" + to_utf8(queryparams.querystring) + (text_t)"\"";
    122123 
    123124  text_t xml_text = "";
     
    125126#ifdef __WIN32__
    126127  //FILE *PIN = _popen(cmd.getcstr(), "r"); // didn't seem to work
    127 
    128   cmd = (text_t)"bin\\windows\\perl\\bin\\perl.exe -S "+cmd;
     128  cmd = (text_t)"perl -S "+cmd;
     129  // we write the result to a file
    129130  clock_t this_time = clock();
    130131  text_t filename = "luc";
    131132  filename.append(this_time);
    132133  filename.append(".txt");
    133   //cerr << "filename = "<<filename<<endl;
     134 
    134135  text_t out_file = filename_cat(collectdir, filename);
    135   cmd += (text_t)" > "+ out_file;
    136   //cerr << "cmd ="<<cmd<<endl;
    137   system(cmd.getcstr());
    138  
    139   read_file(out_file, xml_text);
    140   remove(out_file.getcstr()); // now delete it
    141  
    142 
     136  cmd += (text_t)" \""+out_file+ (text_t)"\"";
     137  int rv = gsdl_system(cmd, true, cerr);
     138  if (rv != 0) {
     139    cerr << "tried to run command \""<<cmd<<"\", but it failed\n";
     140  } else {
     141    read_file(out_file, xml_text);
     142    remove(out_file.getcstr()); // now delete it
     143  }
    143144#else
    144145  FILE *PIN = popen(cmd.getcstr(), "r");
     
    150151    return false;
    151152  }
    152 
    153 
    154153  while (!feof(PIN)) {
    155154    char buffer[256];
     
    160159#endif
    161160  expat_resultset(xml_text,queryresult);
    162 
     161 
    163162#ifdef __WIN32__
    164163  //  _pclose(PIN);
     
    168167
    169168  return true;
    170 
     169}
    171170  /*
    172171  // use default query info settings - change to reflect user preferences??
     
    248247  */
    249248
    250   return false;
    251 
    252 }
    253 
    254249
    255250bool lucenesearchclass::browse_search(const queryparamclass &queryparams,
Note: See TracChangeset for help on using the changeset viewer.