linux中java调用shell脚本
2016-02-25 15:43
746 查看
全部代码
------------------------------------------------------------------------------------------------------------------------------
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
public class RunShell {
public static void main(String[] args) {
try {
Process process = Runtime.getRuntime().exec("shell绝对路径/shell名称 参数1 参数2");
InputStreamReader ir = new InputStreamReader(process.getInputStream());
LineNumberReader input = new LineNumberReader(ir);
String line;
while((line = input.readLine()) != null)
System.out.println(line);
input.close();
ir.close();
} catch (IOException e) {
// TODO: handle exception
e.printStackTrace();
}
}
}
转自:http://blog.csdn.net/heyetina/article/details/6555746
------------------------------------------------------------------------------------------------------------------------------
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
public class RunShell {
public static void main(String[] args) {
try {
Process process = Runtime.getRuntime().exec("shell绝对路径/shell名称 参数1 参数2");
InputStreamReader ir = new InputStreamReader(process.getInputStream());
LineNumberReader input = new LineNumberReader(ir);
String line;
while((line = input.readLine()) != null)
System.out.println(line);
input.close();
ir.close();
} catch (IOException e) {
// TODO: handle exception
e.printStackTrace();
}
}
}
转自:http://blog.csdn.net/heyetina/article/details/6555746
相关文章推荐
- ansible模块command、shell、raw、script
- xshell里面使用黑色背景时蓝色字体看不清楚的解决方法
- shell printf命令:格式化输出语句
- shell 中数学计算总结
- 如何在shell脚本中判断文件或者文件夹是否存在?
- 如何在shell脚本中判断文件或者文件夹是否存在?
- 如何在shell脚本中判断文件或者文件夹是否存在?
- Powershell工作流中的function和script
- shell的if语句
- Shell命令行下如何查找并替换多个文件中的字符
- shell的for循环语句
- Shell的select语句
- shell中$( )与${ }及$(( ))的区别
- Powershell 工作流实战(1)
- shell 文本过滤器和SQL的比较
- 使用srcrpm包重新编译bash使之能够输出日志到rsyslog的local1
- Powershell工作流的限制
- linux shell脚本监控进程,如果进程不在,则重启之
- mac上的终端bash命令(一) Bourne-Again Shell简介\mac上的终端bash命令(二)基础
- JS + shell 批量下载 喜马拉雅FM 的音频