jeudi 25 juin 2015

Process Builder Not showing complete output in console

The output I get By a running a command in cmd is read by ProcessBuilder and printed on console.

import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.*;
public class diskSpace2 {
    public static void main(String[] args) throws Exception {
        diskSpace2 d1=new diskSpace2();
        System.out.println(System.currentTimeMillis());
        Process P1=d1.Read_return("testpc", "testpc", "d:\\superman");

        BufferedReader reader1 = new BufferedReader(new InputStreamReader(
                P1.getInputStream()));
         String readline1;
        //String[] readline1_substring; 



            while((readline1 = reader1.readLine()) != null)
            {
                System.out.println(j+":-->"+readline1);
                j++;
            }
            System.out.println("Process complete");
            System.out.println(System.currentTimeMillis());

    }

    public Process Read_return(String host_name, String domain_name, String vault_path) throws Exception
    {
        File file=new File("C:\\Users\\Tiger\\Downloads\\PSTools\\");

        String cmd1="PsExec \\\\";
        String cmd2 =" -u ";
        String cmd5="\\test -p testpc75 -accepteula -w ";
        String cmd6=" cmd /c dir";
        String cmd_final=cmd1+host_name+cmd2+domain_name+cmd5+vault_path+cmd6;

        //System.out.println("Command = "+cmd_final);

        String cmd_second="dir";
        //System.out.println(System.currentTimeMillis());
        ProcessBuilder pb = new ProcessBuilder("cmd","/C", cmd_final);
        pb.directory(file);
        Process p = pb.start();

        //BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));




       String readline;

        /*while((readline = reader.readLine()) != null)
        {
            System.out.println(readline);
        }*/
        /*System.out.println("Process complete");
        System.out.println(System.currentTimeMillis());*/
        return p;
    }

}

When I run the command stored in cmd_final in my command prompt I get a output like image attached

enter image description here

But the Output I am getting is like this :-

1435231493982

0:--> Volume in drive D is APP

Process complete

1435231575680

I want ProcessBuilder to show the complete OUTPUT on the console.

Aucun commentaire:

Enregistrer un commentaire