You can't directly run a batch file, you need a command interpreter to do it
for you.  Try exec'ing "command.com /c b.bat" on Windows9x or "cmd.exe /c
b.bat" on WindowsNT.
    (*Chris*)

----- Original Message -----
From: Mukul Gandhi <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, August 06, 1999 1:22 PM
Subject: Re: Process and Runtime classes


> Hi,
> I am using the code below suggested by Srini in a test program, but
> strangely its hanging. Its not even going into infinite loop.
>
> A very small code I have written is :
>
> import java.io.*;
>
> public class t
> {
>   public static void main(String[] args)
>   {
>     try
>     {
>       Process proc = Runtime.getRuntime().exec("b.bat");
>       BufferedReader br = new BufferedReader(new
> InputStreamReader(proc.getInputStream()));
>       String line = "";
>       int i = 0;
>       while ((line = br.readLine()) != null)
>       {
>         System.out.println(i+" "+line.length());
>         i++;
>         System.out.println("end while loop");
>       }
>     }
>     catch(IOException ex)
>     {
>
>     }
>   }
> }
>
> b.bat is a dos batch file . I have used the following contents in b.bat
> @echo off
> echo "<HTML>"
> echo "<BODY>"
> echo "<H1>Hello World !</H1>"
> echo "</BODY>"
> echo "</HTML>"
>
> When I run the above class as c:\java t , I get the following output
> 0 8
> end while loop
> 1 8
> end while loop
> 2 24
> end while loop
> 3 9
> end while loop
> 4 9
> end while loop
>
> AND the program hangs, it does,nt go into infinite loop even. I am
> perplexed. Can somebody pl find the reason for this ?
>
> -mukul
>
>
>
> At 08:05 AM 8/5/99 +0530, you wrote:
> >Hi susan,
> >
> >        I have successfullly ran a shell script with the following
command
> >and now we have running a deamon too with this command, hope this snippet
> >shall help u
> >
> >                        **********
> >
> >       Process proc = Runtime.getRuntime().exec("sh ss.s");
> >        BufferedReader br = new BufferedReader(new
> InputStreamReader(proc.getInp
> >utStream()));
> >        String line = "";
> >        while ((line = br.readLine()) != null)
> >        {
> >            System.out.println(line);
> >        }
> >    }
> >
> >Srini
>
>
___________________________________________________________________________
> 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