Thanks for all the code suggestions!! I have received several notes, both
public and private, regarding this question. I have learned from each
example and have even pasted some of the warning comments into the doc for
the class.

----- Original Message -----
From: Ken Klinner <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, February 10, 2000 9:15 PM
Subject: Re: Calling a Windows Line Command from a Servlet


> > I have a servlet which needs to interact with another application. The
> > problem is that the application normally works from commands entered at
a
> > DOS prompt window. I need to be able to invoke the command and trap the
> > output. I think I have seen this done before but can't remember where.
> >
>
> int result = 0;
> Process proc = null;
> try
> {
>     proc = Runtime.getRuntime().exec("yourCommand.exe arg1 arg2 arg3");
>     // Refer to java.lang.Runtime for other ways to invoke exec()
>
>     BufferedReader in = new BufferedReader(new
> InputStreamReader(proc.getInputStream()));
>     BufferedReader err = new BufferedReader(new
> InputStreamReader(proc.getErrorStream()));
>     PrintWriter out = new PrintWriter(proc.getOutputStream(),true);
>     do
>     {
>         // Send some output
>         // Read some input from the standard input or standard error
stream
>         // etc.
>     } while (true);
> }
> catch (IOException e)
> {
> }
> finally
> {
>     result = proc.exitValue();
> }
>
> ------------------------------------------------------------
> Ken Klinner
> [EMAIL PROTECTED]                             www.opiom.com
> ------------------------------------------------------------
>
>
___________________________________________________________________________
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources: http://java.sun.com/products/servlet/external-resources.html
> LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
>

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to