troubleshooting Question

why always "ReadConsoleInput failed" on standard error

Avatar of summer_soccer
summer_soccer asked on
Java
9 Comments1 Solution530 ViewsLast Modified:
Hi,

I am using Java ProcessBuilder class to execute external exe file, and process the standard output and standard error from the external  exe file. I have attached my code as below.

But when I tried to print out the standard error, it always has "ReadConsoleInput failed".

In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is ReadConsoleInput failed: 6
In stand error, the line is
In stand error, the line is --- 84.122.134.1 hping statistics ---
In stand error, the line is 2 packets transmitted, 0 packets received, 100% packet loss
In stand error, the line is round-trip min/avg/max = 0.0/0.0/0.0 ms

Does anybody know why is this?
String exePath = System.getProperty("user.dir")+"\\hping.exe";
							System.out.println("The exe path is " + exePath);
							Process p = new ProcessBuilder(exePath, "-S", ipStr, "-c", "2", "-p", portStr).start();
							
							InputStream is = p.getInputStream();
						    InputStreamReader isr = new InputStreamReader(is);
						    BufferedReader br = new BufferedReader(isr);
						    
				            StreamGobbler errorGobbler = new StreamGobbler(p.getErrorStream(), "ERROR", ipStr);            
			            
				            // any output?
				            StreamGobbler outputGobbler = new StreamGobbler(p.getInputStream(), "OUTPUT", ipStr);
			                
				            // kick them off
				            errorGobbler.start();
				            outputGobbler.start();
			                                    
				            // any error???
				            int exitVal = p.waitFor();
				            System.out.println("ExitValue: " + exitVal);   
						    
						    
						    System.out.println("Exiting one ping!");
 
 
.......
.......
.......
 
			class StreamGobbler extends Thread
			{
			    InputStream is;
			    String type;
			    String str;
			    
			    StreamGobbler(InputStream is, String type, String ipStr)
			    {
			        this.is = is;
			        this.type = type;
			        this.str = ipStr;
			    }
			    
			    public void run()
			    {
			        try
			        {
			        	if (type.equals("OUTPUT")) {
			        		InputStreamReader isr = new InputStreamReader(is);
			        		BufferedReader br = new BufferedReader(isr);
 
						    int ttl = fetchTTL(br);
						    
						    System.out.println("The ttl is "+ttl);
						    
						    if (ttl != -2) {
						    	int hop = calHop(ttl);
						    	
						    	System.out.println("The hop is "+hop);
						    	
						    	synchronized(peerHopTab) {
						    		peerHopTab.put(str, new Integer(hop));
						    		System.out.println(""+str+" hop " + ttl + " is put in hashtable");
						    	}
						    }
			        	}
			        	else {
			        		InputStreamReader isr = new InputStreamReader(is);
			        		BufferedReader br = new BufferedReader(isr);
			        		String line=null;
			        		while ( (line = br.readLine()) != null) {
			        			// do not do anything for error message
			        			System.out.println("In stand error, the line is " + line);
			        		}
			        	}
			          }
			        catch (IOException ioe)
		        	{
		                // ioe.printStackTrace();  
		        	}
			     }
			} // end class StreamGobbler
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 9 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 9 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros