public void doit_wait() throws JRexecException {
    if(thread!=null) return; // ??

    try	{
      write();

      byte[] b=new byte[1];
      in.read(b, 0, 1);  

      byte[] buf=new byte[1024];

      if(b[0]==0){   // success
        while(true){
	  int len=in.read(buf, 0, buf.length);
	  if(len==-1) break;
	  //System.out.print(new String(buf, 0, len));
	}
      }
      else{          // error message
        StringBuffer sb=null;
        while(true){
	  int len=in.read(buf, 0, buf.length);
	  if(len==-1) break;
	  //System.out.print(new String(buf, 0, len));
          if(sb==null){
            sb=new StringBuffer();
	  }
          sb.append(new String(buf, 0, len));
	}
        close();
        if(sb!=null){
          throw new JRexecException(sb.toString());
	}
      }
    }
    catch(IOException e) {
      close();
      //System.out.println("IO Error : " +  e );
      throw new JRexecException(e.toString());
    }
  }