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

    Default Java and Command line interaction

    I am trying to interact with the command line prompt and script the responses for some config. When asked if user wishes to continue I would like respond yes or no, however I would like this response to be automated without any user interaction. I am able to launch the .exe file however when the command prompt is launched I cannot get any further responses to it.

    p
    Java Code:
    ublic 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");
    	           while ((s = stdInput.readLine()) != null) {
    	        	   System.out.println(s);
    At this point cmd is launched and first question is :
    Update the registry automatically
    I would like the response to be no
    NO
    And move on to next option:
    Database Directory [C:/eyetest/database/data]

    Response:
    leave it as default

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,041
    Rep Power
    10

    Default Re: Java and Command line interaction

    Have you tried writing to the output stream of the process? That's just a guess, but I would expect this kind of thing to be on google. What have you tried? Can you post an MCVE instead of a disconnected snippet?
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. Replies: 4
    Last Post: 01-02-2013, 09:50 PM
  2. User interaction command-line
    By kkid in forum New To Java
    Replies: 8
    Last Post: 10-29-2012, 02:37 PM
  3. Replies: 16
    Last Post: 09-17-2011, 03:41 AM
  4. Replies: 2
    Last Post: 07-02-2010, 03:20 PM
  5. Unable to execute command line command in java
    By LordSM in forum New To Java
    Replies: 1
    Last Post: 08-08-2007, 01:23 AM

Posting Permissions

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