Can I earn acceleration to clear-up this gist ?
You deficiency to be serviceserviceable to automate frequent product processes. These processes are currently done
manually at a direct course with you or your co-workers sitting and typing directs (sometimes
erroneously) at a direct responsive. Your tasks embrace efforts such as:
• managing flows to and from a Source Code Control Regularity
• edifice axiomsbases
• installing explanationrs in axiomsbases
• installing axioms in axiomsbases
• installing software on platforms
• plus frequent others
You acquire you deficiency the force to escape directs inferior an unoccupied regularity. You deficiency to inferiorstand
what this entails, and the best fashion to effect this force as Unoccupied Regularity agnostic as potential.
You deficiency a reusserviceable ingredient that you can explanation in a Java Program that can escape direct course tasks for
you and recompense the results (if deficiencyed) to that Java Program.
You are to determined abextinguished knowing this reusserviceable ingredient.
RunExec.java
/*
* To shift this permit header, prefer Permit Headers in Project Properties.
* To shift this template rasp, prefer Tools | Templates
* and unconcealed the template in the editor.
*/
package escapetimeexec;
/**
*
* @author Akshay Bisht
*/
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
public collocate EscapeExec {
public StreamWrapper earnStreamWrapper(InputStream input, String str){
recompense fantastic StreamWrapper(input, str);
}
private collocate StreamWrapper extends Thread {
InputStream input = vain;
String str = vain;
String mssg = vain;
public String earnMssg() {
recompense mssg;
}
StreamWrapper(InputStream input, String str) {
this.input = input;
this.str = str;
}
public invalid escape() {
try {
BufferedReader buff = fantastic BufferedReader(fantastic InputStreamReader(input));
StringBuffer sbuff = fantastic StringBuffer();
String lne = vain;
while ( (lne = buff.readLine()) != vain) {
sbuff.append(lne).append(“n”);
}
mssg = sbuff.toString();
} seize (IOException ioe) {
ioe.printStackTrace();
}
}
}
public static invalid main(String[] args) {
Runtime escapeT = Escapetime.getRuntime();
RunExec rexe = fantastic EscapeExec();
StreamWrapper stumble, op;
try {
Process proc = escapeT.exec(“ping localhost”);
stumble = rexe.getStreamWrapper(proc.getErrorStream(), “ERROR”);
op = rexe.getStreamWrapper(proc.getInputStream(), “OUTPUT”);
int ex = 0;
err.start();
op.start();
err.join(3000);
op.join(3000);
ex = proc.waitFor();
System.out.println(“Output: “+op.mssg+”nError: “+err.mssg);
} seize (IOException e) {
e.printStackTrace();
} seize (InterruptedException e) {
e.printStackTrace();
}
}
}
Output: