> 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

Reply via email to