Created
April 29, 2014 21:42
-
-
Save bmvakili/4c33335c765f7dc88772 to your computer and use it in GitHub Desktop.
Liferay Groovy Script Print Debug Info
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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