Java中的JSP怎么调用shell脚本
摘要:Java中的JSP怎么调用shell脚本
java代码
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%@page import="java.io.InputStreamReader"%> <%@page import="java.io.LineNumberReader"%> <%@page import="java.io.IOException"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; String tel=request.getParameter("tel"); if(tel == null)tel=""; if(!"".equals(tel)){ try { Process proc=Runtime.getRuntime().exec("sh /home/web/wd_test/lt_test.sh "+tel); InputStreamReader ir = new InputStreamReader(proc.getInputStream()); LineNumberReader input = new LineNumberReader(ir); String line; while ((line = input.readLine()) != null) { out.print(line+"<br/>"); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title></title> </head> <body> <form action="lt.jsp"> 请输入手机号:<input type="text" value="<%=tel %>" name="tel"/> <input type="submit" value="提交"/> </form> <%if(!"".equals(tel)){ %> 操作成功 <%} %> </body> </html>
相关文章
最新发布
阅读排行
热门文章
猜你喜欢