【发布时间】:2013-06-23 21:00:24
【问题描述】:
我想下载svn数据,不幸的是它在svn+ssh url上,所以我必须总是输入密码。要通过一个程序调用获得所有版本,我想跳过密码输入。为此,我需要输入脚本的密码,所以至少我不能用一个简单的 shell 脚本来做到这一点,所以我尝试了 Java。我实际写的方法是这样的:
public static void main(String args[]) throws InterruptedException,
IOException {
String user = args[0];
String passwd = args[1];
String url = args[2];
String command = "svn checkout svn+ssh://" + user + "@" + url;
Process p = Runtime.getRuntime().exec(command);
System.out.println("Start");
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(
p.getOutputStream()));
BufferedReader inp = new BufferedReader( new InputStreamReader(p.getInputStream()) );
BufferedReader stderr = new BufferedReader(new InputStreamReader( p.getErrorStream ()));
String line = "";
System.out.println("Waiting...");
while ( line!=null)
{
Thread.sleep(100);
if ( inp.ready())
{
line = inp.readLine();
System.out.println("Line: " + line);
}
if ( stderr.ready())
{
line = stderr.readLine();
System.out.println("Line: " + line);
}
}
out.write(passwd + '\n');
out.write(passwd + '\n');
p.waitFor();
}
很遗憾,这不起作用。我什至没有在输出中得到 Password-Enter-Thing,它只写在控制台上。有谁知道如何传递密码?
我一直在搜索这个,但答案是“也阅读黑啤酒(我已经在阅读)或通过 --password 给 svn 密码,这在我的情况下不起作用。有人知道如何解决这个问题?
最好的问候 达格雷
【问题讨论】:
-
不能为SSH设置公钥认证?
-
--password在什么意义上不起作用?