package com.jcraft.util; import java.io.*; import java.net.*; import java.lang.*; public class JRexec implements Runnable { private Thread thread=null; private InputStream data=null; private InputStream in=null; private OutputStream out=null; private boolean devnull=true; private Socket socket=null; String user=null; String host=null; String passwd=null; String command=null; public JRexec(String user, String host, String passwd, String command) throws JRexecException { this.user=user; this.host=host; this.passwd=passwd; this.command=command; try{ socket = new Socket(host, 512); in = socket.getInputStream(); out = socket.getOutputStream(); } catch(java.net.UnknownHostException e){ throw new JRexecException(e.toString()); } catch(java.io.IOException e) { throw new JRexecException(e.toString()); } } public JRexec(String user, String host, String passwd, String command, InputStream data) throws JRexecException { this(user, host, passwd, command); this.data=data; } public JRexec(String user, String host, String passwd, String command, String data) throws JRexecException { this(user, host, passwd, command); this.data=new ByteArrayInputStream(data.getBytes()); } public synchronized InputStream getResult(){ if(thread!=null || !devnull) return null; devnull=false; return in; } public synchronized void doit(){ if(thread==null){ thread=new Thread(this); thread.start(); } } public void run() { try { // port out.write(0); int chop=8; if(user.length()