gpt4 book ai didi

python - 重定向 'git clone' 的 stdout/stderr/stdin

转载 作者:太空狗 更新时间:2023-10-30 00:08:14 26 4
gpt4 key购买 nike

我想编写一个程序来克隆远程 git 存储库,然后做一些其他的事情。问题是“git clone”要求输入密码。当我打开到 stdin/out/err 的管道到“git clone”时,它不起作用,因为它在下面运行 git-remote-http,提示在 TTY 上输入密码。

我想从我的程序中传递密码。我正在使用子进程中的 Python 和 Popen。下面的代码不起作用。

Popen(['git', 'clone', 'https://my.git.repo/repo.git'], shell=False, stdin=PIPE, stdout=PIPE, stderr=PIPE)

我怎样才能做到这一点?

最佳答案

如果您不想像评论者所说的那样使用质询身份验证,我会使用 pexpect使这种交互自动化

关于python - 重定向 'git clone' 的 stdout/stderr/stdin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8325204/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com