2012-12-01 40 views
1

我嘗試使用apache commons-exec來運行git clone命令但卡住了,它根本沒有提示我輸入密碼並在那裏阻止。使用apache commons-exec運行git clone:如何輸入密碼?

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

任何想法來解決這個問題?

回答

1

我想出一個辦法來解決這個問題,只是包裝的用戶名和passwd爲InputStream的:

String input="...";   
executor.setStreamHandler(new PumpStreamHandler(System.out, System.err, new ByteArrayInputStream(
      input.getBytes()))); 
+0

什麼是在這種情況下,輸入字符串格式?你知道這是否適合git pull嗎? –