Last active
May 19, 2016 20:29
-
-
Save badvision/9913f6c9974bca5d549c370d4065088b to your computer and use it in GitHub Desktop.
Call the *nix command line "df -h" to obtain the disk usage of the server
This file contains 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
<%@page session="false" contentType="text/html; charset=utf-8" | |
pageEncoding="UTF-8" import="java.lang.*,java.io.*"%><% | |
Process p = Runtime.getRuntime().exec("df",new String[]{"-h"}); | |
p.waitFor(); | |
%><h2>STDERR:</h2><pre><% | |
String line; | |
BufferedReader error = new BufferedReader(new InputStreamReader(p.getErrorStream())); | |
while((line = error.readLine()) != null){ | |
%><%=line%> | |
<% | |
} | |
error.close(); | |
%></pre><h2>STDOUT:</h2><pre><% | |
BufferedReader input = new BufferedReader(new InputStreamReader(p.getInputStream())); | |
while((line=input.readLine()) != null){ | |
%><%=line%> | |
<% | |
} | |
input.close(); | |
%> | |
</pre> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment