Hi,
I'm attaching a sample Unix specific code. Hope it is okay.
This sample works fine on Solaris, HPUX but not on Redhat Linux AS 2.1.
I'm using jdk 1.4.2 and
tomcat version 4.0.4.
However, the problem goes away when I use tomcat version 5.0. Any thoughts ? The problem is I cannot replace tomcat 4.0.4 with tomcat 5.0. Is there anyway I can work around the problem in tomcat 4.0.4 itself ?
Thanks and regards,
Anu
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class HelloWorld extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
PrintWriter out = response.getWriter();
Runtime r = Runtime.getRuntime();
out.println("Executing command");
Process p = r.exec("ls /tmp");
try {
String str = null;
InputStream inS = p.getInputStream();
InputStreamReader inSr = new InputStreamReader(inS);
BufferedReader inR = new BufferedReader(inSr);
while ((str = inR.readLine()) != null) {
out.println(str);
try {
Thread.sleep(100);
} catch (Exception e) {}
}
inR.close();
} catch (IOException ioe) {
ioe.printStackTrace();
}
}
}