// check if sudo password is correct (so sudo can be used in all other scripts, even without
  // password, lasts for 5 minutes)
  private void doSudoCmd() {
    String pass = passwordField.getText();

    File file = null;
    try {
      // write file in /tmp
      file = new File("/tmp/cmd_sudo.sh"); // ""c:/temp/run.bat""
      FileOutputStream fos = new FileOutputStream(file);
      fos.write("echo $password | sudo -S ls\nexit $?".getBytes()); // "echo $password > pipo.txt"
      fos.close();

      // execute
      HashMap vars = new HashMap();
      vars.put("password", pass);

      List oses = new ArrayList();
      oses.add(
          new OsConstraint(
              "unix", null, null,
              null)); // "windows",System.getProperty("os.name"),System.getProperty("os.version"),System.getProperty("os.arch")));

      ArrayList plist = new ArrayList();
      ParsableFile pf = new ParsableFile(file.getAbsolutePath(), null, null, oses);
      plist.add(pf);
      ScriptParser sp = new ScriptParser(plist, new VariableSubstitutor(vars));
      sp.parseFiles();

      ArrayList elist = new ArrayList();
      ExecutableFile ef =
          new ExecutableFile(
              file.getAbsolutePath(),
              ExecutableFile.POSTINSTALL,
              ExecutableFile.ABORT,
              oses,
              false);
      elist.add(ef);
      FileExecutor fe = new FileExecutor(elist);
      int retval = fe.executeFiles(ExecutableFile.POSTINSTALL, this);
      if (retval == 0) {
        idata.setVariable("password", pass);
        isValid = true;
      }
      //			else is already showing dialog
      //			{
      //				JOptionPane.showMessageDialog(this, "Cannot execute 'sudo' cmd, check your password",
      // "Error", JOptionPane.ERROR_MESSAGE);
      //			}
    } catch (Exception e) {
      //				JOptionPane.showMessageDialog(this, "Cannot execute 'sudo' cmd, check your password",
      // "Error", JOptionPane.ERROR_MESSAGE);
      e.printStackTrace();
      isValid = false;
    }
    try {
      if (file != null && file.exists())
        file.delete(); // you don't want the file with password tobe arround, in case of error
    } catch (Exception e) {
      // ignore
    }
  }