----------------------------------------------------------------
BEFORE YOU POST, search the faq at <http://java.apache.org/faq/>
WHEN YOU POST, include all relevant version numbers, log files,
and configuration files. Don't make us guess your problem!!!
----------------------------------------------------------------
Hi,
I have a problem in my Servlets. I need to execute commands from inside my
servlets. I can execute commands from the shell by using "java comline"...
and this works fine.
import java.io.*;
public class comline {
public static void main(String[] arguments) {
try {
Runtime.getRuntime().exec("mkdir ItWorked");
} catch(IOException ex) {
System.err.println("IOException : " + ex.getMessage());
}
}
}
However the following code.......
import javax.servlet.http.*;
import javax.servlet.ServletException;
import java.io.*;
import java.util.*;
public class test extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse
response)throws IOException
HttpSession UserSession = request.getSession(true);
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<HTML>");
out.println("<BODY>");
out.println("<h5>Current Date : " + new Date() + "</h5>");
try {
Runtime.getRuntime().exec("mkdir ItWorked");
} catch(IOException ex) {
System.err.println("IOException : " + ex.getMessage());
}
out.println("</body></html>");
out.close();
}
}
This does not work. My system setup is. SuSE 6.3 i386, apache 1.3.11 with
jserv 1.1.
Does anyone know why this command will not execute?
Some possible reasons I have looked at are :
1. Setting the user to somebody other than nobody and then giving ownership
of the directory to them.
2. Path to mkdir not set.
However none of these changes made any effect. Another intresting thing is
it reports no error's. However if I try and use .....
Runtime.getRuntime().exec("java comline");
>From inside the servlet, it report the error that it can't find the file
java. It obviously doesn't use the same path's as bash. I am stumped can
anyone help me?
Thanks,
Keith
---------------------------------------------------------------------------
Keith Ball - Praktikant
WA46 Operationelle Analysen Luftwaffe
IABG MbH Einsteinstr. 20 85521 Ottobrunn
Phone : 0049-89-6088-2556
Email : [EMAIL PROTECTED] WWW site : www.iabg.de
----------------------------------------------------------------------------
--
--------------------------------------------------------------
Please read the FAQ! <http://java.apache.org/faq/>
To subscribe: [EMAIL PROTECTED]
To unsubscribe: [EMAIL PROTECTED]
Archives and Other: <http://java.apache.org/main/mail.html>
Problems?: [EMAIL PROTECTED]