Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » Apache Tomcat »

Re: Runtime.getRuntime.exec() problem

hui zhang

2007-01-14

Replies:

Zack Grafton wrote:
> hui zhang wrote:
>> Hi Everybody,
>>
>> Now I am trying to launch an external application, for example, "top"
>> ,in my web application, and killing it by PID after a while. But when
>> I execute Runtime.getRuntime.exec("top") in my JSP page or Servlet,
>> Tomcat is stuck in that page and do not display anything because it
>> can not stop running until that "commnad" is terminated, which means
>> it waiting for the response from Runtime.getRuntime.exec("top"). It
>> seems that it will run forever. Is there any solution to solve this
>> problem? I mean that JSP page can execute the following code no
>> matter if it finish the process is done.
>>
>> BTW, I do not use System.exit() in my program. It may cause Security
>> Manager problem.
>> Thanks and best regards,
>>
>> Hui
>>
>> ---------------------------------------------------------------------
>> To start a new topic, e-mail: users@(protected)
>> To unsubscribe, e-mail: users-unsubscribe@(protected)
>> For additional commands, e-mail: users-help@(protected)
>>
>>
> Hey,
>
> I'm new to the list and all, but you might want to try executing "top"
> in batch mode. The command line option is -b on my gentoo linux box.
> Also, be careful of executing commands from applets and such. Another
> thing might be user permissions as well. You could try executing the
> command and redirecting the output to a file and parsing the file
> instead.
>
> Zack Grafton
>
> ---------------------------------------------------------------------
> To start a new topic, e-mail: users@(protected)
> To unsubscribe, e-mail: users-unsubscribe@(protected)
> For additional commands, e-mail: users-help@(protected)
Hi,

"TOP" is only an example in this case. Actually I am running some
program which can not stop running until terminating it by "Control +
C". In this case, Tomcat can not run the following code if the external
application does not stop. I need a solution to make my webapp running
in this case. Thank you.

Regards,

Hui




---------------------------------------------------------------------
To start a new topic, e-mail: users@(protected)
To unsubscribe, e-mail: users-unsubscribe@(protected)
For additional commands, e-mail: users-help@(protected)

©2008 junlu.com - Jax Systems, LLC, U.S.A.