Apendice 1-4 (Execute.java)

import java.io.DataInputStream; public class Execute extends java.lang.Object implements Runnable { String info; String data; boolean done; public Execute (String info) { this.info = info; this.data = null; done = false; } public void run() { doTask(info); pause(20); done = true; System.out.println("the work has been done..."); } private void doTask(String data) { Runtime rt = Runtime.getRuntime(); Process proc; StringBuffer buffer = new StringBuffer(); java.util.StringTokenizer st = new java.util.StringTokenizer(data, ";"); while(st.hasMoreElements()) { String item = (String)st.nextElement(); String cmd = "/home/u/raid/vol14/is085855/prueba " + item.trim().toLowerCase(); try { proc = rt.exec(cmd); DataInputStream in = new DataInputStream(proc.getInputStream()); byte b[] = new byte[256]; int read; while((read = in.read(b))!= -1) { buffer.append(new String(b, 0, 0, read)); } proc.waitFor(); } catch(Exception e) { System.out.println("Error doing doTask: " + e.getMessage()); } } this.data = buffer.toString(); } private void pause(long seconds) { java.util.Date time = new java.util.Date(); System.out.println("started at:" + time.toString()); try { Thread.sleep(1000 * seconds); } catch(java.lang.InterruptedException e) {} time = new java.util.Date(); System.out.println("ending at:" + time.toString()); } public String getData() { return (String)data; } }