原帖:http://chenyaqiong81081.blog.163.com/blog/static/44622594200791235256255/
一、Runtime.getRuntime().exec()執(zhí)行命令情況:
Runtime.getRuntime().exec("cmd /c your command")//2000
Runtime.getRuntime().exec("command /c your command")//98
Runtime.getRuntime().exec("sh/ your command")//linux
二、執(zhí)行.sh文件的情況:
1、把命令寫成a.sh ;執(zhí)行命令的時(shí)候
Process child = Runtime.getRuntime().exec("bash a.sh,null,new File("http://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()等待操作完成
posted on 2009-12-29 17:10
rox 閱讀(2861)
評(píng)論(0) 編輯 收藏