I am trying to write a servlet that will execute a application and then give
access to the inputs and output streams of that process.  After a large
amount of headache I have written a test program just to test the streams.
I just CAN"T seem to get it to work. I am including the TEST code.  ANY help
would be really really useful. I have looked over this a hundred times and I
can't find anything that is wrong.

Thanks in advance

Aaron Kane






import java.io.*;

public class ThisStinks {
  private Process proc;
  private Runtime rt =Runtime.getRuntime();
  private BufferedReader read;
  private BufferedWriter write;

  public ThisStinks() {
  }
  public boolean exec (){
    try{
    String command[] = {"/usr/openwin/bin/xterm","-display","myIP:0.0"};
    proc = rt.exec(command);
    return(true);
    }catch(Exception e){return(false);}
  }//end of exec

  public boolean init (){
    try{
    read = new BufferedReader(new InputStreamReader(proc.getInputStream()));
    write = new BufferedWriter(new
OutputStreamWriter(proc.getOutputStream()));
    return(true);
    }catch(Exception e){return (false);};
  }//end of init

  public boolean read(){
    try{
    while(true){
      System.out.println(read.readLine());}
    }catch(Exception e){return (false);};
  } //end of read

  public boolean write(String input){
    try{
      write.write(input + "\n");
      write.flush();
      return(true);
    }catch(Exception e){return (false);};
  } //end of read

  public static void main(String args[]){

      ThisStinks hellyea = new ThisStinks();
      if(!hellyea.exec())System.out.println("error 1");
      if(!hellyea.init())System.out.println("error 2");

      try{
      Thread.sleep(4000);
      hellyea.write("vi");
      System.out.println("input active");
      hellyea.read();
      }catch(Exception e){System.out.println("System crash");}


  }//end of main


}// end of class

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to