Skip the pause command in a batch from a java process -
i'm using java process
class execute batch files. i'm using processbuilder
create process , part run fine. problem deal pause
command in batch file i'm running. pause
command hanging execution of batch, need batch finish, can resume pending operations. currently, i'm starting batch code equivalent this:
import java.io.bufferedreader; import java.io.file; import java.io.inputstreamreader; import java.util.arrays; import java.util.list; public class batchenter { public static void main(string[] args) throws exception { list<string> params = arrays.aslist(new string[]{"cmd", "/c", "c:/test/test.bat"}); processbuilder builder = new processbuilder(params); builder.directory(new file("c:/test")).redirecterrorstream(true); process p = builder.start(); bufferedreader wr = new bufferedreader(new inputstreamreader(p.getinputstream())); string line = ""; while((line = wr.readline())!=null){ system.out.println(line); } p.waitfor(); } }
i'm aware can use "hack" skip pause
command batch file. but, problem can't change of batch files i'm using , can't add batch file call batch in link provided.
i wondering there way specify process skip pause command?
as assylias said, need open output stream , send commands script. pauses.
sending commands console application?
has examples. 1 thing i've done before read 1 line @ time. if line string matches prompt request, send linefeed whenever happens. way don't have worry scripts have prompts or how often.
Comments
Post a Comment