0
我想使用脚本从git下载源代码。如何在命令导致提示时自动输入字符串?
以下git
命令的结果提示:
git clone ssh://url.com/repo.git git_test3
Cloning into 'git_test3'...
The authenticity of host 'url.com (1.1.1.1)' can't be established.
ECDSA key fingerprint is .
Are you sure you want to continue connecting (yes/no)?
我制定了以下脚本,以便通过脚本输入“yes”自动:
#!/bin/sh
git_clone() {
git clone ssh://url.com/repo.git test <<EOF > /dev/null
yes
EOF
}
git_clone
,但它不工作。该脚本始终导致提示(yes/no)
。
我错过了什么?
你可以用'expect'脚本来做你想做的事情。请参阅http://expect.sourceforge.net/ – Wolf
尝试** yes **命令,它可能工作。试试这个,是的,是的git clone ssh://url.com/repo.git test',请参阅http://stackoverflow.com/questions/8416887/is-the-program-yes-used-for-anything-significant – ishaan
@ishaan这只是另一个向'git'的标准输入提供重复文本的方式,这是OP已经在做的事情。问题在于它不是'git'请求响应,它是'ssh','ssh'不是从标准输入读取,而是直接从终端读取。 – chepner