Homework Solution: Can I get help to solve this problem ?…

    Can I get help to solve this problem ? You need to be able to automate many development processes. These processes are currently done manually at a command line with you or your co-workers sitting and typing commands (sometimes erroneously) at a command prompt. Your tasks include efforts such as: • managing flows to and from a Source Code Control System • building databases • installing users in databases • installing data in databases • installing software on platforms • plus many others You realize you need the ability to run commands under an operating system. You need to understand what this entails, and the best way to make this ability as Operating System agnostic as possible. You need a reusable component that you can use in a Java Program that can run command line tasks for you and return the results (if needed) to that Java Program. You are to set about designing this reusable component.

    Expert Answer

     
    RunExec.java /* * To change this license header

    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.

    Expert Tally

     

    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: