我正在使用cygwin和java运行shell脚本。如何在进程中编写命令生成器
ProcessBuilder pb =new ProcessBuilder
("sh", "app.sh", "ib2", "12", "11", "AK-RD", "02.20", "D:\\cygwin\\bin\\test\\delta");
我的脚本正在运行,当我硬编码参数。我想通过文本框的值传递这些参数。
如何做到这一点。
String cmmd[] = new String[8];
cmmd[0] ="\"sh\"";
cmmd[1] ="\"app.sh\"";
cmmd[2] ="\""+txt_threeltr.getText()+"\"";
cmmd[3] ="\""+txt_month_c.getText()+"\"";
cmmd[4] ="\""+txt_year_C.getText()+"\"";
cmmd[5] ="\""+txt_partNumber.getText()+"\"";
cmmd[6] ="\""+txt_version.getText()+"\"";
cmmd[7] ="\""+txt_destinationname.getText()+"\"";
ProcessBuilder pb =new ProcessBuilder(Arrays.toString(cmmd));
或者有没有其他的方法来做到这一点。
感谢它工作正常。 – 2012-02-21 14:01:45