private void test(String shScript,String tableName,String logpath){ InputStream in = null; try {//读取脚本文件路径,参数名1,参数名2 Process pro = Runtime.getRuntime().exec(new String[]{"sh", shScript,tableName,logpath}); pro.waitFor(); in = pro.getInputStream(); BufferedReader read = new BufferedReader(new InputStreamReader(in)); String result = null; while((result=read.readLine())!=null){ System.out.println("INFO:"+result); } } catch (Exception e) { e.printStackTrace(); }
Java 实现读取shell命令
最新推荐文章于 2024-06-29 14:58:08 发布