code: protected static String runCommand (String cmd)
      {
          try {
              Process p = Runtime.getRuntime().exec(cmd);
              BufferedReader cin = new BufferedReader(new InputStreamReader(p.getInputStream()));
              StringBuilder buffer= new StringBuilder();
  
              String line = "";
              while (line != null)
              {
                  buffer.append(line);
                  line = cin.readLine();
              }
              cin.close();
  
              return buffer.toString();
          } catch (IOException e) {
              // don't want to log anything for the client to know what we are doing.
              // This will almost always be thrown/caught when the cmd isn't there.
              return null;
          }
      }
docs: Run the specified command and return the output as a string.