运行多个OS命令

时间:2014-01-01 13:20:15

标签: java process exec

如何在Java中运行多个OS命令?我正在使用以下代码来运行OS命令:

System.out.println("Please Insert an URL ");

String https_url = input.next();
ProcessBuilder builder = new ProcessBuilder("cmd.exe", "/c", "cd \"C:\\OpenSSL\" && openssl s_client -connect "+https_url);
    builder.redirectErrorStream(true);
    Process pr = builder.start();
    BufferedReader r = new BufferedReader(new InputStreamReader(pr.getInputStream()));
    String line;
    while (true)
        {
            line = r.readLine();
            if (line == null)
                break;
     System.out.println(line);
}

运行上面的命令后,我需要再运行两个命令 -

  1. HEAD / HTTP / 1.1
  2. R以检查会话重新协商。
  3. 如何在同一个OpenSSL窗口中运行多个命令?

0 个答案:

没有答案