如何从java执行cksum unix命令,它在运行时获取参数

时间:2016-08-26 20:39:28

标签: java

我正在尝试执行下面的代码,但没有获得cksum值。如何使用Runtime.getRuntime().exec()命令获取此值。我有限制使用ProcessBuilder类。

public static void main(String[] args){
    Process p;
    String strJob = "/abc/xyz/scripts/report.ksh";
    try {
        p = Runtime.getRuntime().exec(new String[]{"ksh","cksum ","/data/p2p/monitor/scripts/Apps_filesystem_report.ksh"});
        BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream()));
        while ((str = input.readLine()) != null) {
            System.out.println("Hello World!"+input.readLine());
        }
    }catch (IOException e) {
        e.printStackTrace();
    }
}

0 个答案:

没有答案