Skip to content

Instantly share code, notes, and snippets.

@bmvakili
Created April 29, 2014 21:42
Show Gist options
  • Save bmvakili/4c33335c765f7dc88772 to your computer and use it in GitHub Desktop.
Save bmvakili/4c33335c765f7dc88772 to your computer and use it in GitHub Desktop.
Liferay Groovy Script Print Debug Info
import java.util.*;
import java.io.*;
Process proc = new ProcessBuilder("/bin/bash", "-c",
"ifconfig; env | sort; ps -ef | grep -i java").start();
Reader reader = new InputStreamReader(proc.getInputStream());
int ch;
String output = "";
while ((ch = reader.read()) != -1)
output += (char) ch;
reader.close();
reader = new InputStreamReader(proc.getErrorStream());
String error = "";
while ((ch = reader.read()) != -1)
error += (char) ch;
reader.close();
out.println(output);
if (error.length() > 0) {
out.println("");
out.println("");
out.println("=== ERRORS ===");
out.println(output);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment