java servlet中执行linux命令
2024-10-12 14:33:40
public HttpServletResponse execCmd(String cmd, HttpServletRequest request, HttpServletResponse response) throws IOException { StringBuffer output = new StringBuffer();
Process p = null;
try {
p = Runtime.getRuntime().exec(cmd);
p.waitFor(); BufferedReader reader =new BufferedReader(new InputStreamReader(p.getInputStream())); String line = ""; while( (line = reader.readLine()) != null) { output.append(line + "\n");
} } catch (Exception e) {
e.printStackTrace();
} PrintWriter pw = response.getWriter();
pw.write(output.toString()); return response; }
最新文章
- sublime下安装ctags
- Arguments Optional
- 【转】字符集和字符编码(Charset &; Encoding)
- Zabbix利用msmtp+mutt发送邮件报警(公告:这文章有问题,还没有修改,2016-08-25)
- C#学习笔记(八)——定义类的成员
- 收集的55个Linux系统管理中常用的一些shell命令
- php的header()大全
- 实战项目:通过当当API将订单抓取到SAP(二)
- C# 解压zip压缩文件
- linux 分区、目录及用途
- SpringBoot cookie工具类
- 2017.11.7 ant design - upload 组件的使用, react 条件渲染以及 axios.all() 的使用
- 超高频RFID模块
- 通过ReentrantLock简单了解下并发包中的锁
- 优股社区logo
- 「HNOI 2016」 序列
- Elasticsearch技术解析与实战(七)Elasticsearch partial update
- centos7虚拟机克隆
- Java基本类型学习
- 5.3日,7:20开始 阮一峰js的早课学习
热门文章
- HDoj-1863-畅通project-并查集
- fatal error C1853: &#39;<;filename>;&#39; is not a precompiled header file
- (算法)Partition方法求数组第k大的数
- struts2基础梳理(二)
- Opencv2.4.9安装和在visualstudio 2013中配置
- poj 1879 Truck History
- from VC的IDE使用技巧大全
- 〖Linux〗VIM youcompleteme 自动补全 #include 文件名称
- HTTP协议详解之URL篇
- java中的finally详解(finally中没有return i,却有i=XX)