publicstaticStringexecShell(StringshellString){System.out.println("将要执行的shell语句是:"+shellString);StringisOK="ok";try{Processprocess=Runtime.getRuntime().exec(shellString);BufferedReaderinput=newBufferedReader(newInputStreamReader(process.getInputStream()));Stringline="";while((line=input.readLine())!=null){System.out.println(line);}input.close();intexitValue=process.waitFor();if(0!=exitValue){isOK="no";System.err.println("callshellfailed.errorcodeis:"+exitValue);}}catch(Throwablee){e.printStackTrace();}returnisOK;}这是我在java中用过的一个调用shell的函数,你可以试试;执行成功返回ok,执行失败返回no