- Timestamp:
- 2008-03-25T19:49:33+13:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gli/trunk/src/org/greenstone/gatherer/shell/GShell.java
r15110 r15125 227 227 private void runLocal(String[] args, BufferedOutputStream bos) 228 228 { 229 boolean execArgs = false; 229 230 try { 230 231 String command = ""; 231 for(int i = 0; i < args.length; i++) { 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 } 232 236 command = command + args[i] + " "; 233 237 } … … 238 242 Runtime rt = Runtime.getRuntime(); 239 243 Process prcs = null; 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 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 245 253 InputStreamReader eisr = new InputStreamReader( prcs.getErrorStream(), "UTF-8" ); 246 254 InputStreamReader stdisr = new InputStreamReader( prcs.getInputStream(), "UTF-8" );
Note:
See TracChangeset
for help on using the changeset viewer.