Package winterwell.utils

Examples of winterwell.utils.Process.run()


   */
  public static List<String> getMyIP() {
    if (Utils.OSisUnix()) {
      Process p = new Process("ifconfig");
      try {
        p.run();
        p.waitFor(2000);
        String out = p.getOutput();
        Matcher m = IP4_ADDRESS.matcher(out);
        ArrayList<String> ips = new ArrayList<String>();
        while (m.find()) {
View Full Code Here


      // even on a busy server (2 seconds was too little on egan).
      Process p = new Process("wkhtmltopdf "
          + (waitFor == null ? "" : waitFor) + " "
          + temp1.getAbsolutePath() + " " + file.getAbsolutePath());
      p.setEcho(true);
      p.run();
      int done = p.waitFor(TUnit.MINUTE.getMillisecs());

      if (!file.exists())
        throw new IOException("Failed to create " + file + "\t"
            + p.getError());
View Full Code Here

      assert temp1.exists() && temp1.length() > 0;

      // 2. Render, trim and convert to PNG with convert
      Process p2 = new Process("convert -trim -antialias -density 300 "
          + temp1.getAbsolutePath() + " " + file.getAbsolutePath());
      p2.run();
      p2.waitFor(TUnit.MINUTE.getMillisecs());

      if (!file.exists())
        throw new IOException("Failed to create " + file + "\t"
            + p2.getError());
View Full Code Here

      // try an OS call
      if (Utils.getOperatingSystem().contains("linux")
          || Utils.getOperatingSystem().contains("unix")) {
        String path = file.getAbsolutePath();
        Process p = new winterwell.utils.Process("rm -f " + path);
        p.run();
        p.waitFor(1000);
        if (!file.exists())
          return;
        throw new WrappedException(new IOException(
            "Could not delete file " + file + "; " + p.getError()));
View Full Code Here

  private static void deleteNative(File out) {
    if (!Utils.OSisUnix())
      throw new TodoException("" + out);
    Process p = new winterwell.utils.Process("rm -f "
        + out.getAbsolutePath());
    p.run();
    int ok = p.waitFor();
    if (ok != 0)
      throw new IORException(p.getError());
  }
View Full Code Here

    String x = "";
    if (!returnIP && IP4_ADDRESS.matcher(site).matches()) {
      x = "-x ";
    }
    Process p = new Process("dig +short " + x + site);
    p.run();
    p.waitFor(5000); // this should be fast -- 5 seconds allows aeons of
              // time
    String out = p.getOutput();

    // look for an IPv4 address?
View Full Code Here

    } catch (UnsupportedOperationException ex) {
      // KDE isn't supported :(
      if (Utils.getOperatingSystem().contains("linux")
          || Utils.getOperatingSystem().contains("unix")) {
        Process p = new Process("xdg-open " + uri);
        p.run();
      } else
        throw ex;
    } catch (IOException e) {
      throw new IORException(e);
    }
View Full Code Here

    // Attempt to run external command
    try {
      final File md = File.createTempFile("tmp", ".md");
      FileUtils.write(md, text);
      Process process = new Process(cmd+" "+md.getAbsolutePath());
      process.run();
      int ok = process.waitFor(10000);
      if (ok != 0) throw new FailureException(cmd+" failed:\n"+process.getError());
      String html = process.getOutput();
      FileUtils.delete(md);
      return html;
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.