Changeset 15154


Ignore:
Timestamp:
2008-03-29T18:10:09+13:00 (14 years ago)
Author:
ak19
Message:

runLocal() method now uniformly executes a process with arguments instead of a single string composed of the multiple arguments. Spaces in filepaths are preserved. But this required a change to how mkcol.pl was executed from CollectionManager.java

File:
1 edited

Legend:

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

    r15125 r15154  
    227227    private void runLocal(String[] args, BufferedOutputStream bos)
    228228    {
    229     boolean execArgs = false;
    230229    try {
    231230        String command = "";
    232         for(int i = 0; i < args.length && !execArgs; i++) {
    233         if(args[i].indexOf(' ') != -1) { // if any argument contains spaces, then we'll have to
    234            execArgs = true; // execute it with argument array rather than command item
    235         }
     231        for(int i = 0; i < args.length; i++) {
    236232        command = command + args[i] + " ";
    237233        }
     
    242238        Runtime rt = Runtime.getRuntime();
    243239        Process prcs = null;
    244         if (Utility.isWindows() || execArgs){ // if execArgs=true, then we're on Linux and one or more arguments
    245         // contained spaces, meaning we'll have to execute it with an argument array rather than command item.
    246         // This is especially necessary if one of the args is a filepath containing spaces in the filename or path
    247         prcs = rt.exec(args);
    248         } else { // we're on Linux and none of the arguments contains any spaces,
    249         // so just execute with single string argument (command)
    250         prcs = rt.exec(command);
    251         }
    252                    
     240     
     241        prcs = rt.exec(args);
     242        // If we used single argument exec, spaces in filenames or paths cause problems
     243        // I.e. better to avoid: prcs = rt.exec(command);
     244       
    253245        InputStreamReader eisr = new InputStreamReader( prcs.getErrorStream(), "UTF-8" );
    254246        InputStreamReader stdisr = new InputStreamReader( prcs.getInputStream(), "UTF-8"  );       
     
    270262            sleep(100);
    271263            }
    272             catch(Exception exception) {
     264            catch(Exception exception) {         
    273265            }
    274266        }
Note: See TracChangeset for help on using the changeset viewer.