- Timestamp:
- 2008-03-29T18:10:09+13:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gli/trunk/src/org/greenstone/gatherer/shell/GShell.java
r15125 r15154 227 227 private void runLocal(String[] args, BufferedOutputStream bos) 228 228 { 229 boolean execArgs = false;230 229 try { 231 230 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++) { 236 232 command = command + args[i] + " "; 237 233 } … … 242 238 Runtime rt = Runtime.getRuntime(); 243 239 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 253 245 InputStreamReader eisr = new InputStreamReader( prcs.getErrorStream(), "UTF-8" ); 254 246 InputStreamReader stdisr = new InputStreamReader( prcs.getInputStream(), "UTF-8" ); … … 270 262 sleep(100); 271 263 } 272 catch(Exception exception) { 264 catch(Exception exception) { 273 265 } 274 266 }
Note:
See TracChangeset
for help on using the changeset viewer.