需要 SVN 身份验证时获取 STDERR 输出失败
Getting STDERR output fails when SVN authenticaion needed
我正在尝试执行 svn update
命令,但由于我没有通过此命令传递用户名和密码,它要求我提供这些凭据。但是我需要记录这个命令的 STDERR 输出。
这就是现在正在发生的事情:
record = `svn update 2>&1`
它输出:
Authentication realm: <https://url_of_repository:443> url_of_repository SVN Repository
Username:
并且它停止执行,因为它希望用户输入凭据。但我想将上面的输出记录为变量中的字符串,以便我可以将用户名和密码传递给它。我该怎么做。
感谢您的帮助。
这可以通过在您的命令中传递 --non-interactive
参数来完成,这样它就不会提示输入身份验证凭据。
所以在你的情况下:
output = `svn update "#{repo_path}" --non-interactive 2>&1`
check_authentication = output.include?("Authentication failed")
如果身份验证失败,check_authentication
将 return true
。
我正在尝试执行 svn update
命令,但由于我没有通过此命令传递用户名和密码,它要求我提供这些凭据。但是我需要记录这个命令的 STDERR 输出。
这就是现在正在发生的事情:
record = `svn update 2>&1`
它输出:
Authentication realm: <https://url_of_repository:443> url_of_repository SVN Repository
Username:
并且它停止执行,因为它希望用户输入凭据。但我想将上面的输出记录为变量中的字符串,以便我可以将用户名和密码传递给它。我该怎么做。
感谢您的帮助。
这可以通过在您的命令中传递 --non-interactive
参数来完成,这样它就不会提示输入身份验证凭据。
所以在你的情况下:
output = `svn update "#{repo_path}" --non-interactive 2>&1`
check_authentication = output.include?("Authentication failed")
如果身份验证失败,check_authentication
将 return true
。