执行 mount 命令 exitValue 返回 1
手动执行却可以,命令如下
sudo mount -t cifs -o username="",password="" //192/192 /server/tomcat6.0/webapps/abc/share/123
java 执行命令函数代码如下:
try {
String[] cmdArray = new String[] { "/bin/sh", "-c", shStr };
Process process = Runtime.getRuntime().exec(cmdArray);
InputStreamReader ir = new InputStreamReader(
process.getInputStream());
LineNumberReader input = new LineNumberReader(ir);
while ((line = input.readLine()) != null) {
result.append(line).append("\n");
}
process.waitFor();
input.close();
ir.close();
int exitValue=process.exitValue();
if(exitValue!=0){
log.loger.info("Command ("+shStr+") return value is : " + process.exitValue());
return Constant.ERROR;
}
} catch (Exception e) {
// TODO: handle exception
e.printStackTrace();
}