如何通過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