日期:2014-05-20 浏览次数:20938 次
public void doExecUnixCMD(String folder) throws SinocpcException,
IOException {
String cmdString = "";
try {
// Process exec = null;
int chmod = 0, cd = 0, zip = 0;
// 1.赋文件夹权限
cmdString = "chmod 777 /was/rdccs/rdccsdev/www/export";
GlobalVariable.log.debug("1.赋文件夹权限: " + cmdString);
chmod = Runtime.getRuntime().exec(cmdString).waitFor();
GlobalVariable.log.debug("chmod=, cd= , zip=" + chmod + "," + cd
+ "," + zip);
// 2.执行压缩命令
//cmdString = "tar -cvf " + folder + ".tar.gz " + folder + "/*";
cmdString = "zip -r " + folder + ".zip " + folder + "/*";
GlobalVariable.log.debug("2.执行压缩命令: " + cmdString);
zip = Runtime.getRuntime().exec(cmdString).waitFor();
} catch (Exception e) {
// e.printStackTrace();
GlobalVariable.log.debug("压缩命令执行失败:" + e.getMessage() + "命令"
+ cmdString);
}
/*
* finally { bufferedReader.close(); }
*/
GlobalVariable.log.debug("AAA压缩命令执行结束");
}