You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Pankaj Malviya <pa...@internetdevices.com> on 2000/10/05 00:28:54 UTC

How to call Runtime.exec()

Hi,

I am trying to start my application server ( If it has been killed or
stopped) from Servlet by using runtime.exec() and it is not working. Do I
need to make some changes in config file or somewhere to make this happen. I
read that to do this in iPlanet Web Server some config changes are required,
whether same is the case for tomcat.

Your early help will be highly appreciated.

Wondering why my application server dies. (It is killed by process watch on
the Shared Hosting Server).


Regards

Pankaj


RES: [tomcat-devel] How to call Runtime.exec()

Posted by Sergio Stateri Jr <st...@tesla.com.br>.
Here's a sample JSP that run any System command, since the user that run
Tomcat has sufficient rights...

PS : Send the command to be executed as the "command" URL parameter, like
this :

http://server/run_command.jsp?command=ls%20-l

(see that the command must be URL Encoded...)


Sergio Stateri Jr
stateri@tesla.com.br
Tesla Tecnologia
Sao Paulo (SP) Brazil

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

<html>
<body>

<%
	String s;

	try {
	    Process myProcess =
Runtime.getRuntime().exec(request.getParameter("command"));

	    DataInputStream in = new DataInputStream(
		new BufferedInputStream(myProcess.getInputStream()));

	    while ((s = in.readLine()) != null) {
		out.println(s + "<br>");
	    }
	}
	catch (IOException e) {
	    out.println("Error: " + e);
	}
%>

</body>
</html>




-----Mensagem original-----
De: tomcat-devel-admin@lists.real-time.com
[mailto:tomcat-devel-admin@lists.real-time.com]Em nome de Pankaj Malviya
Enviada em: Quarta-feira, 4 de Outubro de 2000 19:29
Para: tomcat-dev@jakarta.apache.org
Assunto: [tomcat-devel] How to call Runtime.exec()

Hi,

I am trying to start my application server ( If it has been killed or
stopped) from Servlet by using runtime.exec() and it is not working. Do I
need to make some changes in config file or somewhere to make this happen. I
read that to do this in iPlanet Web Server some config changes are required,
whether same is the case for tomcat.

Your early help will be highly appreciated.

Wondering why my application server dies. (It is killed by process watch on
the Shared Hosting Server).


Regards

Pankaj


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-dev-help@jakarta.apache.org

_______________________________________________
tomcat-devel mailing list
tomcat-devel@lists.real-time.com
https://mailman.real-time.com/mailman/listinfo/tomcat-devel


RE: How to call Runtime.exec()

Posted by Scott Stirling <ss...@mediaone.net>.
You should post questions like this on the tomcat-user group.

The description you've provided needs to be more detailed.  Don't make others
figure out your problem.  For example:

"it is not working"

and

"Wondering why my application server dies."

Are way too vague for anyone to do more than make a wild guess.

Scott Stirling
West Newton, MA

> -----Original Message-----
> From: Pankaj Malviya [mailto:pankajm@internetdevices.com]
> Sent: Wednesday, October 04, 2000 6:29 PM
> To: tomcat-dev@jakarta.apache.org
> Subject: How to call Runtime.exec()
>
>
> Hi,
>
> I am trying to start my application server ( If it has been killed or
> stopped) from Servlet by using runtime.exec() and it is not working. Do I
> need to make some changes in config file or somewhere to make this happen. I
> read that to do this in iPlanet Web Server some config changes are required,
> whether same is the case for tomcat.
>
> Your early help will be highly appreciated.
>
> Wondering why my application server dies. (It is killed by process watch on
> the Shared Hosting Server).
>
>
> Regards
>
> Pankaj