Runtime.getRuntime().exec学习记录[转贴]
2010-12-03 16:33
253 查看
原帖:http://chenyaqiong81081.blog.163.com/blog/static/44622594200791235256255/
一、Runtime.getRuntime().exec()执行命令情况:
Runtime.getRuntime().exec("cmd /c your command")//2000
Runtime.getRuntime().exec("command /c your command")//98
Runtime.getRuntime().exec("sh/ your command")//linux
二、执行.sh文件的情况:
1、把命令写成a.sh ;执行命令的时候
Process child = Runtime.getRuntime().exec("bash a.sh,null,new File("//usr/local/mysql/bin/"));
child.waitFor();
........
2、Process child = Runtime.getRuntime().
exec(new String[] {"/bin/sh","-c","mysqldump -u root -p7788919 axtic_cg" },
null,
new File("/usr/local/mysql/bin/"));
child.waitFor();
注:waitFor()等待操作完成
一、Runtime.getRuntime().exec()执行命令情况:
Runtime.getRuntime().exec("cmd /c your command")//2000
Runtime.getRuntime().exec("command /c your command")//98
Runtime.getRuntime().exec("sh/ your command")//linux
二、执行.sh文件的情况:
1、把命令写成a.sh ;执行命令的时候
Process child = Runtime.getRuntime().exec("bash a.sh,null,new File("//usr/local/mysql/bin/"));
child.waitFor();
........
2、Process child = Runtime.getRuntime().
exec(new String[] {"/bin/sh","-c","mysqldump -u root -p7788919 axtic_cg" },
null,
new File("/usr/local/mysql/bin/"));
child.waitFor();
注:waitFor()等待操作完成
相关文章推荐
- Runtime.getRuntime().exec()----记录日志案例
- Java 使用Runtime.getRuntime.exec 和 ProcessBuilder 调用外部命令
- java Runtime.getRuntime().exec 调用系统脚本/命令注意事项
- 20110215 学习记录2:表单中的get和post区别 & 使用 HttpWebRequest 向网站提交数据
- 1、java设置Linux系统时间之 System.getRuntime.exec()
- 关于java Runtime.getRunTime.exec(String command)的使用
- cin cin.get() cin.getline() 2017年7月2日学习记录
- Runtime.getRuntime().exec
- 关于Runtime.getRuntime().exec("su");
- Eclipse下使用Runtime.getRuntime().exec启动java程序的问题
- 使用Runtime.getRuntime().exec()在java中调用python脚本
- Runtime.getRuntime().exec执行阻塞问题解决
- Java Process中waitFor()的问题(使用Runtime.getRuntime().exec(...)时)
- Runtime.getRuntime.exec(String)与exec(String[])的区别
- Runtime.getRuntime().exec() 输出流阻塞的解决方法
- Runtime.getRuntime().exec()方法的使用
- RunTime.getRuntime().exec()运行脚本命令介绍和阻塞
- RunTime.getRuntime().exec()运行脚本命令介绍和阻塞
- apk使用adb shell命令 Process p = Runtime.getRuntime().exec(cmd)
- Runtime.getRuntime().exec()