Results 1 to 5 of 5
  1. #1
    mademoiselle is offline Member
    Join Date
    Mar 2012
    Posts
    21
    Rep Power
    0

    Default StdInput and StdOutput

    Java Code:
    public static void runConfigure(String[] refBox1,String outDir2)
    	 	throws IOException{
    		 
    	        String s = null;
    	 
    	        try {
    	             
    	        // run the Unix "ps -ef" command
    	            // using the Runtime exec method:
    	        
    	        	Process p = Runtime.getRuntime().exec("cmd.exe /c C:\\eyetest\\install\\configure.exe  text");
    	        	
    	            BufferedReader stdInput = new BufferedReader(new
    	                 InputStreamReader(p.getInputStream()));
    	            
    	            BufferedWriter stdOutput = new BufferedWriter(new
    		                 OutputStreamWriter(p.getOutputStream()));
    	           	           
    	            BufferedReader stdError = new BufferedReader(new
    	                 InputStreamReader(p.getErrorStream()));
    	      
    	   
    	 	       
    	         	            
    	            // read the output from the command
                    	
    	           System.out.println("Here is the standard output of the command: \n ");
    	           int ch;
    	           while ((ch = stdInput.read()) != -1) {
    	        	   	 System.out.print((char)ch);
    	        	   	 
    
    	            }

    the above code returns:

    [Ljava.lang.String;@1c8825a5
    Index[0]=ent-14-0-win-20140417.zip
    Here is the standard output of the command:

    os name: windows 7
    Running on Windows
    Host Identifier:
    To improve system performance strongly recommend the server's MaxUserPort registry value is increased to 65534 (for more details see the Getting Started Guide).
    Update the registry automatically [Yes]>



    based on the above output , how would i go about feeding my response to configure as either yes or no and going on to the next configure option. I do understand this may seem very easy and straight forward for some , please kindly understand it is not for me, your help and feedback would be appreciated.

  2. #2
    RamyaSivakanth's Avatar
    RamyaSivakanth is offline Senior Member
    Join Date
    Apr 2009
    Location
    Chennai
    Posts
    842
    Rep Power
    6

    Default Re: StdInput and StdOutput

    u can go for Scanner class for getting userinput.i hope this only u ask.
    pls refer this link
    Java.util.Scanner.next() Method Example
    Ramya:cool:

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,663
    Blog Entries
    7
    Rep Power
    21

    Default Re: StdInput and StdOutput

    This can be a nice read: When Runtime.exec() won't | JavaWorld

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  4. #4
    mademoiselle is offline Member
    Join Date
    Mar 2012
    Posts
    21
    Rep Power
    0

    Default Re: StdInput and StdOutput

    Quote Originally Posted by RamyaSivakanth View Post
    u can go for Scanner class for getting userinput.i hope this only u ask.
    pls refer this link
    Java.util.Scanner.next() Method Example
    What I am after is a method that will enable me read and write for several options presented by cmd.

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,663
    Blog Entries
    7
    Rep Power
    21

    Default Re: StdInput and StdOutput

    Quote Originally Posted by mademoiselle View Post
    What I am after is a method that will enable me read and write for several options presented by cmd.
    Read the link I supplied in my previous reply.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •