CMD operations through Java -


i'm trying run command line operations through java. 1 of command requires enter pressed complete. don't know how pass enter through java in middle of command execution.

    import java.io.bufferedreader; import java.io.inputstreamreader;  public class commandlinemethods { public static string executecommand(string []command) {     stringbuffer output = new stringbuffer();     process p;     try{                   p=runtime.getruntime().exec(command);          p.waitfor();         bufferedreader br = new bufferedreader(new inputstreamreader(p.getinputstream()));         string line = "";         while((line=br.readline())!=null)         {             output.append(line + "\n");         }     }     catch(exception e)     {         e.printstacktrace();     }     return output.tostring(); } public static void main(string...args) {        string scriptspath ="c:\\bip_autochain\\win64_x64\\scripts";     string scriptname="lcm_cli.bat";     string scriptarguments="lcmproperty c:\\testng_auto\\resources\\lcmbiar_import.property";      string []command = {"cmd.exe", "/c"," cd "+scriptspath+" && "+ scriptname +" -"+scriptarguments};     string res = executecommand(command);     system.out.println(res);  }  } 

last command running script argument requires enter pressed complete. how achieve so?

it looks you'll need create thread , send key inside of it. simple coordination send child sleep.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -