Question

I try to use apache commons-exec to run git clone command but stuck, it did not prompt me with password input at all and block there.

DefaultExecutor executor = new DefaultExecutor();
executor.setStreamHandler( new PumpStreamHandler( System.out, System.err, System.in ) );
executor.execute( "git clone --progress -v https://xxx/prj.git" );

Any ideas to solve this?

Was it helpful?

Solution

I figure out a way to work around this problem, just wrap the user name and passwd as inputstream:

String input="...";        
executor.setStreamHandler( new PumpStreamHandler( System.out, System.err, new ByteArrayInputStream(
            input.getBytes() ) ) );
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top