Hi all,
When I use commons-exec to call os script like .bat on windows,I meet
problem.
the bat script like this:
del /p d:\133.mht
dir
When use commons-exec to call this,There no pause after "del /p
d:\133.mht",and "dir" command execute.
The code shows as follow:
File testDir = new File(
"D:/eclipse_works/exec/opensource/exec/src/test/scripts");
File testScript = TestUtil.resolveScriptForOS(testDir + "/test");
File printArgsScript = TestUtil
.resolveScriptForOS(testDir + "/deltest");
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PumpStreamHandler pumpStreamHandler = new PumpStreamHandler(baos, baos);
pumpStreamHandler.start();
Executor exec = new DefaultExecutor();
exec.setStreamHandler(pumpStreamHandler);
// exec.setStreamHandler(new PumpStreamHandler(baos, baos));
CommandLine cl = new CommandLine(printArgsScript);
exec.execute(cl);
System.out.println("out===== " + baos.toString().toString());
when run:
out=====
D:\eclipse_works\exec>del /p d:\133.mht
d:\133.mht,要删除(Y/N)吗?
D:\eclipse_works\exec>dir
驱动器 D 中的卷没有标签。
卷的序列号是 C850-03F6
D:\eclipse_works\exec 的目录
2010-08-10 20:35 <DIR> .
2010-08-10 20:35 <DIR> ..
2010-08-10 20:38 495 .classpath
2010-08-10 20:35 380 .project
2010-08-10 20:35 <DIR> .settings
2010-08-10 20:38 <DIR> bin
2010-08-10 20:35 <DIR> opensource
2010-08-10 20:35 <DIR> src
2 个文件 875 字节
6 个目录 13,176,107,008 可用字节
how to resolve this problem?
thanks ahead
2010-08-12
刘东