Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Regex 需要重复输入用户名和密码的脚本_Regex_Svn_Git_Ssh_Expect - Fatal编程技术网

Regex 需要重复输入用户名和密码的脚本

Regex 需要重复输入用户名和密码的脚本,regex,svn,git,ssh,expect,Regex,Svn,Git,Ssh,Expect,我有一个脚本,需要在subversion存储库中的各个分支之间切换,以便进行复制。这导致必须重复输入密码。现在,一旦我做了几次这件事,我就很熟悉我的剧本了。我搞砸了,惹得我非常生气 我以前使用过expect在提示符下输入密码。我希望学习如何让expect一次又一次地运行多个密码提示,直到任务完成 到目前为止,这就是我所拥有的 #!/usr/bin/expect global env set timeout 10 spawn command that requires password expec

我有一个脚本,需要在subversion存储库中的各个分支之间切换,以便进行复制。这导致必须重复输入密码。现在,一旦我做了几次这件事,我就很熟悉我的剧本了。我搞砸了,惹得我非常生气

我以前使用过expect在提示符下输入密码。我希望学习如何让expect一次又一次地运行多个密码提示,直到任务完成

到目前为止,这就是我所拥有的

#!/usr/bin/expect
global env
set timeout 10
spawn command that requires password
expect "^user"
send "password\r"
#i need this to repeat over and over until the prompt stops showing up.

请并感谢您。

您是否考虑过使用,这样您就不必反复键入密码了?

天真的暴力方法:

while 1 {
    expect $prompt
    send $password\r
}
更好:

expect {
    $prompt {
        send $password\r
        exp_continue
    }
    timeout {
        puts "haven't seen prompt for $timeout seconds"
    }
    "some pattern that indicates password no longer required"
}
puts "continuing ..."

ssh密钥不起作用,我已经设置好了,但是当我运行这个命令时,它不想检查它们。在我看来,修复这个密钥比让这个脚本起作用更有益。你为什么不改问那个问题呢。如果你把一切都设置正确的话,它应该可以工作。我这样做将使我所有的服务器和生活变得更加轻松。