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

    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.

    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
    	            BufferedWriter stdOutput = new BufferedWriter(new
    	            BufferedReader stdError = new BufferedReader(new
    	            // read the output from the command
    	           System.out.println("Here is the standard output of the command:\n");
    	           while ((s = stdInput.readLine()) != null) {
    At this point cmd is launched and first question is :
    Update the registry automatically
    I would like the response to be no
    And move on to next option:
    Database Directory [C:/eyetest/database/data]

    leave it as default

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

    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 - GameDev tutorials, free Java and JavaScript hosting!
    Static Void Games forum - Come say hello!

Similar Threads

  1. Replies: 4
    Last Post: 01-02-2013, 08:50 PM
  2. User interaction command-line
    By kkid in forum New To Java
    Replies: 8
    Last Post: 10-29-2012, 01:37 PM
  3. Replies: 16
    Last Post: 09-17-2011, 02:41 AM
  4. Replies: 2
    Last Post: 07-02-2010, 02: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, 12: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