如何通过java代码调用shell脚本? 我写下了下面的代码。 我得到的进程退出代码为127. 但似乎我的UNIX机器上的shell脚本从未被调用过。从java获取错误
String scriptName = "/xyz/downloads/Report/Mail.sh";
String[] commands = {scriptName,emailid,subject,body};
Runtime rt = Runtime.getRuntime();
Process process = null;
try{
process = rt.exec(commands);
process.waitFor();
int x = process.exitValue();
System.out.println("exitCode "+x);
}catch(Exception e){
e.printStackTrace();
}
是脚本可执行+ X? –
是的,我已经给了chmod 777 – chandan