Changeset 5075


Ignore:
Timestamp:
2003-08-01T14:44:58+12:00 (21 years ago)
Author:
jmt12
Message:

Fixed problems with supplying config argument to server.exe - changes at line no. 735 and replaced the entirity of ExternalApplication

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gli/src/org/greenstone/gatherer/Gatherer.java

    r5071 r5075  
    732732                gsdlsite_cfg.set();
    733733                // Spawn server
    734                 String[] command = new String[2];
    735                 command[0] = config.exec_file.getAbsolutePath();
    736                 command[1] = gsdlsite_cfg.getSiteConfigFilename();
     734                String command = config.exec_file.getAbsolutePath() + " " + gsdlsite_cfg.getSiteConfigFilename();
    737735                server = new ExternalApplication(command);
    738736                server.start();
     
    759757                    }
    760758
    761                     if(gsdlsite_cfg.getURL() != null) {
     759                    if((url = gsdlsite_cfg.getURL()) != null) {
    762760                        // Ta-da. Now the url should be available.
    763761                        config.exec_address = new URL(url);
     
    847845    private Process process = null;
    848846    /** The initial command string given to this sub-process. */
    849     private String[] command = null;
     847    private String command = null;
     848    private String[] commands = null;
    850849    /** Constructor.
    851850     * @param command The initial command <strong>String</strong>.
    852851     */
    853     public ExternalApplication(String large_command) {
    854         CommandTokenizer tokenizer = new CommandTokenizer(large_command);
    855         while(tokenizer.hasMoreTokens()) {
    856         if(command == null) {
    857             command = new String[1];
    858             command[0] = tokenizer.nextToken();
    859         }
    860         else {
    861             command = ArrayTools.add(command, tokenizer.nextToken());
    862         }
    863         }
    864     }
    865 
    866     public ExternalApplication(String[] command) {
     852    public ExternalApplication(String command) {
    867853        this.command = command;
     854    }
     855
     856    public ExternalApplication(String[] commands) {
     857        this.commands = commands;
    868858    }
    869859    /** We start the child process inside a new thread so it doesn't block the rest of Gatherer.
     
    877867        // Call an external process using the args.
    878868        try {
    879         StringBuffer whole_command = new StringBuffer();
    880         for(int i = 0; i < command.length; i++) {
    881             whole_command.append(command[i]);
    882             whole_command.append(" ");
     869        if(commands != null) {
     870            StringBuffer whole_command = new StringBuffer();
     871            for(int i = 0; i < commands.length; i++) {
     872            whole_command.append(commands[i]);
     873            whole_command.append(" ");
     874            }
     875            println("Running " + whole_command.toString());
     876            Runtime rt = Runtime.getRuntime();
     877            process = rt.exec(commands);
     878            process.waitFor();
    883879        }
    884         println("Running " + whole_command.toString());
    885         whole_command = null;
    886         Runtime rt = Runtime.getRuntime();
    887         process = rt.exec(command);
    888         process.waitFor();
     880        else {
     881            println("Running " + command);
     882            Runtime rt = Runtime.getRuntime();
     883            process = rt.exec(command);
     884            process.waitFor();
     885        }
    889886        }
    890887        catch (Exception error) {
Note: See TracChangeset for help on using the changeset viewer.