jsp如何调用li**x shell

时间:2016.05.02 发布人:hgot1v9nvj5

jsp如何调用li**x shell

已解决问题

谷歌hgot1v9nvj5用户在2016.05.02提交了关于“离歌jsp如何调用li**x shell”的提问,欢迎大家涌跃发表自己的观点。目前共有1个回答,最后更新于2024-12-06T21:31:03。希望大家能够帮助她。

详细问题描述及疑问:期待您的答案,不知道说什么,送你一朵小红花吧 !

希望以下的回答,能够帮助你。

第1个回答

用户名:situhuilin  

经常碰到运营部门人要清缓存,而缓存一村请练界是远书直存在问题,老在电脑面前处理也不是个办法,想了个方法,通过访问一个jsp页面自动清缓存

<%@pagelanguage="j问答**a"import="***.io.*"pageEncoding="UTF-8"%>

<%

Stringpath=request.getContextPath();

Stri手区苏劳会认够ngbasePath=request.getScheme()+":/试到他角/"

+request.getServerName()+":"+request.getServerPort()

+path+"/";

%>

<html>

<head>

<title>shell</title>

</head>

<body>

<%

Stringcmds="***.sh";

try{

Processprocess;

process=Runtime.getRuntime().exec("sh/opt/做wzx/***.sh");

In下已putStreamReaderir=newInputStreamReader(process

.getInpu胡航化影职围tStream());

LineNumberReaderinput=newLineNumberReader(ir);

Stringline;

process.waitFor();

while((line=input.readLine())!=**ll){

out婷紧.print(line);

out.print("<br/>");

}

if(input!=**ll){

input.close();

}

}catch(算极极湖燃请Exceptione){

e.printStack眼边用Trace();

}

%>

</body>

</html>

***.sh脚本内容

裂双执echo'flush_all'|nc192.168.10.7311211

将该脚本放到jboss/server/defau题视便达船措lt/deploy/jboss-web.deployer/ROOT.war/下就可以访问了