00001 import java.io.BufferedInputStream; 00002 import java.io.BufferedOutputStream; 00003 import java.io.BufferedReader; 00004 import java.io.InputStream; 00005 import java.io.InputStreamReader; 00006 import java.io.PrintStream; 00007 00008 00016 public class ShellClient { 00017 00021 public static void main(String[] args) { 00022 try { 00023 BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); 00024 Process p = Runtime.getRuntime().exec("java -cp /usr/wiss/jain/work/code/SRLDB/bin PipeServer"); 00025 BufferedReader fromProbCog = new BufferedReader(new InputStreamReader(p.getInputStream())); 00026 BufferedReader fromProbCogErr = new BufferedReader(new InputStreamReader(p.getErrorStream())); 00027 PrintStream toProbCog = new PrintStream(p.getOutputStream()); 00028 while(true) { 00029 while(fromProbCogErr.ready()) { 00030 System.out.println("Server:Status: " + fromProbCogErr.readLine()); 00031 } 00032 while(fromProbCog.ready()) { 00033 System.out.println("Server:Result: " + fromProbCog.readLine()); 00034 } 00035 if(br.ready()) { 00036 String line = br.readLine(); 00037 toProbCog.println(line); 00038 toProbCog.flush(); 00039 } 00040 } 00041 } 00042 catch(Exception e) { 00043 e.printStackTrace(); 00044 } 00045 } 00046 }