java如何调用linux下的类似cmd命令,谢谢
我在windows下写了一个.bat批处理文件,文件内容:
exp system/manager1@db tables=T_YHXX grants=y file=d:\e.dmp
imp system/ff@dddd tables=T_YHXX grants=y file=d:\e.dmp
exit
就是导入导出,java是这样调用的:
public static void main(String[] args){
try {
String command = "cmd.exe /C start c:\\a.bat";
Process child = Runtime.getRuntime().exec(command);
} catch (IOException e) {
e.printStackTrace();
}
}
请问要是在linux下,有没有对应的cmd的方法,能让它自动执行的语句,sh行不行?请给一段实例,谢谢
[解决办法]
public void startup() { try { Process process = Runtime.getRuntime().exec("sh startup.sh &"); InputStream inputStream = process.getInputStream(); byte[] bs = new byte[1024]; inputStream.read(bs); inputStream.close(); } catch (IOException e) { log.error(e.getMessage()); } }
[解决办法]