Execute multiple commands by outputstream in Java
来源:互联网 发布:sql 字段默认值 编辑:程序博客网 时间:2024/06/07 07:20
public class MyProcess {public static void main(String[] args) {try {// bash, su or any other command invoke a shell interpreter// we execute the commands sent from outputstream by this// interpreterProcess process = Runtime.getRuntime().exec("bash\n");DataOutputStream outputStream = new DataOutputStream(process.getOutputStream());outputStream.writeBytes("echo nothing\n");outputStream.writeBytes("ls -al\n");outputStream.writeBytes("exit\n");outputStream.flush();outputStream.close();process.waitFor();BufferedReader rd = new BufferedReader(new InputStreamReader(process.getInputStream()));String string = null;while ((string = rd.readLine()) != null) {System.out.println(string);}} catch (Exception e) {// TODO: handle exception}}
0 0
- Execute multiple commands by outputstream in Java
- Running system commands in Java applications
- Performing native commands in java code
- Performing native commands in java code
- Running system commands in Java applications
- Example of Unix commands implemented in Java
- how to execute set of commands in elevated mode of powershell
- java OutputStream
- Show multiple tables in one page by using valueList
- GDB commands by function
- How to execute shell script in Java?
- compile the mex files in the Matlab terminal by executing these commands(混合编程)zz
- execute Windows powershell command or .ps1 file by java
- Storing Multiple Values in a Map--by Tim O'Brien 整理by博主
- Special Commands in Doxygen
- [Python] Commands in Django
- Commands in MVVM
- 【Xcode】 Multiple build commands for output file
- 9 storage的状态转换
- hdu1305 Immediate Decodability
- 动态规划之K好数(蓝桥杯ALGO-3)
- 在Android中实现程序前后台切换
- Volley框架使用之请求大量图片
- Execute multiple commands by outputstream in Java
- Linux常用命令大全
- 传纸条(nyoj 61)
- Java正则表达式
- 黑马程序员 Day2 Java基础常量与变量等
- MachineLearning(Hsuan-Tien Lin)第十六讲
- php 导出CSV抽象类
- Android Service被系统回收的解决方法
- [BASIC-15] 字符串对比