Hello mukul,
That is for exclusively for unix shell script for running the
batch files or any dos exe u can directly call
Process proc = Runtime.getRuntime().exec("b.bat"); It will do the
necessary thing. Why to get a inputstreamreader for unix is that it will
store the output in the process object and we can get the output from that
object.
Just try it out in dos and leme know the feedbacks.
Thanks
Srini
#-----------------------------------------------------------------------#
# #
# "ARISE AWAKE and stop not till the GOAL is reached" #
# #
# [EMAIL PROTECTED] #
#-----------------------------------------------------------------------#
On Fri, 6 Aug 1999, Mukul Gandhi wrote:
> 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
Re: Process and Runtime classes
Srinivasan S (Systems Engineering Group) Fri, 6 Aug 1999 17:41:30 -0700
- Process and Runtime classes Susan Moffat
- Re: Process and Runtime clas... Ricky Szeto - CSCI/F95
- Re: Process and Runtime clas... Milt Epstein
- [Offtopic] Re: Process and R... Steve Odendahl
- Re: Process and Runtime clas... Srinivasan S (Systems Engineering Group)
- Re: Process and Runtime clas... Mukul Gandhi
- Re: Process and Runtime ... Chris Pratt
- Re: Process and Runt... Mukul Gandhi
- Srinivasan S (Systems Engineering Group)
