child = Runtime.getRuntime().exec(strCommand);//如果没写授权文件是不会让执行的

解决方案 »

  1.   

    这是答案:
     try{
    child = Runtime.getRuntime().exec(strCommand);

    child.waitFor();

    intExitValue = child.exitValue();

    try{
    BufferedReader bufferedReader = new BufferedReader(
    new InputStreamReader(child.getInputStream()));

    while( (strLine = bufferedReader.readLine()) != null){
    arrSts = arrSts+strLine+",";
    intsts++;
    }
    }
    catch(Exception e){
    throw new Exception("Command not found");
    }
    if (intExitValue == 1){
    throw new Exception("failed:" + arrSts);
    }

    arrSts = arrSts + intsts;

    child.destroy();
    }
    //Command not Exist
    catch(Exception e){ %> 
    <jsp:forward page ="gs_error.jsp">
    <jsp:param name="errorMessage" value="Error:error( <%=e.getMessage()%> )"/>
    </jsp:forward>
    <% }