使用JSP执行Shell并返回结果。
jsp:
String cmd = " /opt/test.sh 2 3333";
try
{
String outStr = "";
// 执行CMD;
Process p = Runtime.getRuntime().exec(cmd);
InputStream processIn = p.getInputStream();
if (processIn != null){
for (int ch = 0;(ch = processIn.read()) != -1;){
outStr += (char) ch;
}
}
out.println(outStr);
}catch(Exception e){
out.println(e.toString());
}
[end]
shell
cat /opt/resin-2.1.13/doc/adcustomer/log/webSystem_$1*.log | grep $2