You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "DonS, Choi" <ds...@dreami.co.kr> on 2000/06/21 11:13:57 UTC

Can't execute Runtime.getRuntime().exec()

Hi,

--- test1.jsp --
<%
        Runtime.getRuntime().exec("/usr/bin/ls > /tmp/test" );
%>

test1.jsp did not execute.

What't the problem?

Thanks advance



Re: Can't execute Runtime.getRuntime().exec()

Posted by Jason Hunter <jh...@collab.net>.
> "DonS, Choi" wrote:
> 
> Hi,
> 
> --- test1.jsp --
> <%
>         Runtime.getRuntime().exec("/usr/bin/ls > /tmp/test" );
> %>
> 
> test1.jsp did not execute.

Problem is ">" is a shell command and Java doesn't exec within a shell. 
You need to run a shell, and pass the arguments to the shell.  It's
outlined in Chapter 13 of my book.  http://www.servlets.com/book. 
Examples are online.

-jh-



Re: Can't execute Runtime.getRuntime().exec()

Posted by Jason Hunter <jh...@collab.net>.
> "DonS, Choi" wrote:
> 
> Hi,
> 
> --- test1.jsp --
> <%
>         Runtime.getRuntime().exec("/usr/bin/ls > /tmp/test" );
> %>
> 
> test1.jsp did not execute.

Problem is ">" is a shell command and Java doesn't exec within a shell. 
You need to run a shell, and pass the arguments to the shell.  It's
outlined in Chapter 13 of my book.  http://www.servlets.com/book. 
Examples are online.

-jh-