Java调用执行linux shell脚本
来源:互联网 发布:羊绒衫怎么洗 知乎 编辑:程序博客网 时间:2024/05/29 21:29
1.创建/home/nh/hello.sh,代码如下所示:
#!/bin/sh
touch /home/nh/shishi.txt
2.新建一个java项目,代码如下:
package javaapplication4;
import java.io.IOException;
public class JavaApplication4 {
public static void main(String[] args)
{
try
{
Runtime.getRuntime().exec("/home/nh/hello.sh").waitFor();
}
catch(IOException e)
{
e.printStackTrace();
}
catch(InterruptedException e)
{
e.printStackTrace();
}
System.out.println("nihao");
}
}
3.执行上述java程序,会发现/home/nh/路径下出现了shishi.txt文件(即脚本所在目录下出现了shishi.txt),说明脚本被执行成功。
0 0
- Java调用执行linux shell脚本
- java调用linux中的shell脚本并返回执行结果
- java 调用linux shell脚本
- linux上Java后台执行SHELL脚本
- linux执行shell脚本
- Linux执行shell脚本
- java调用linux中的shell脚本
- linux中java调用shell脚本
- linux上java调用shell脚本
- java调用Linux 命令、Shell脚本
- Java调用linux系统shell执行命令
- JAVA SHELL脚本执行
- java执行shell脚本
- Java 执行shell 脚本
- 怎样在java代码中调用执行shell脚本
- java调用并执行shell脚本以及问题总结
- java调用Shell脚本
- java调用Shell脚本
- OpenGL(二)图形绘制之多边形面的绘制
- Eclipse 报 "The builder launch configuration could not be found" 错误的解决办法
- LeetCode 86. Partition List
- dwr 整合时报错
- 新公司去国税办理发票业务
- Java调用执行linux shell脚本
- cv::split(img1,planes); cv::merge(planes,result);
- Java设计模式-创建型-单例模式
- dup()系统调用
- Python basic note 01
- css之Margin重叠现象
- 论文笔记--N4-Fields: Neural Network Nearest Neighbor Fields for Image Transforms
- Mac上 IDEA 设置 各字体颜色以及背景颜色设置
- Bootable partition could not be on a logical volume