I am running cmds ok from win200 with tomcat 4.12

have ago wuth this example - It migth be bad code but it works ok with < and > pinted as html escape code (&#60; and &#62;).

Regards,
Simon

<HTML>
<BODY>

<%@page language="java" import="java.sql.*"%>

<%@page import="java.io.*" %>
<%@page import="java.util.*" %>
<%@page import="java.text.*" %>
<%!
public String shellCommand(String cmd) {
try {
Runtime rt = Runtime.getRuntime();
Process p = rt.exec(cmd);
int i;
StringBuffer buf = new StringBuffer();
InputStream os=p.getInputStream();
while((i=os.read()) != -1) {
if (i == 60 )
buf.append("&#60;");
else if (i == 62 )
buf.append("&#62;");
else
buf.append((char)i);
}
return buf.toString();
}catch (Exception e)
{
return "error " + e;
}
}
%>

<h1>ipconfig</h1>
<pre>
<%= shellCommand("cmd /C ipconfig /all ") %>
</pre>

</BODY>
</HTML>






Jason Cheng wrote:

Hi,

Through much trial and error, I finally determined
that using the Runtime.exec() in a JSP page might not
be possible when serving with a Tomcat server that is
being run as a NT service. It seems that when running
Tomcat as a service, it is not possible to call the
console. If I stop the service and load Tomcat as a
stand-alone application, my JSP pages load without a
hitch. Unfortunately, I think we will need to
continue running Tomcat as a service. If that is the
case, is there anyway to run external programs from
JSP pages?
__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus � Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

--
To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to