从命令提示符在 Perl 脚本中输入密码重定向
我正在使用 Windows 系统命令提示符来调用 Perl 脚本。在某一时刻,Perl 脚本调用 svn+ssh 来更新存储库。被调用的存储库要求用户输入 - 特别是密码。
我试图自动执行 Perl 脚本,但它不断地挂起对 svn 的调用。我尝试过多种形式的输入重定向(特别是 <
使用外部文件,|
使用 cat
,以及 Windows Power shell 使用@符号指定多行字符串)。有没有办法为这个 Perl 脚本输入密码?
出于解决此问题的目的,我无法访问 Perl 脚本,并且需要实施解决方法。
I am using a Windows System Command Prompt to call on a Perl Script. At one point and time, the Perl Script calls on svn+ssh
to update a repo. The repository that is called asks the for user input - specifically a password.
I am trying to automate the execution of the Perl Script, but it continually gets hung up on the call to svn. I have tried many forms of input redirection (specifically <
with an external file, |
with cat
, and the windows power shell use of the @ symbol to specify a multi-lined string). Is there a way to input a password for this Perl script?
For purposes of this problem, I do not have access to the Perl Script and I will need to implement a work around.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您没有提到脚本使用的 svn+ssh 实现,但我的猜测是问题是这样的:
SSH 客户端倾向于直接从终端询问密码。密码提示通常不会从标准输入读取,因此您无法重定向输入。例如,OpenSSH 客户端就是这样做的。它的设计目的是防止用户做不安全的事情 - 例如将密码存储在文件、环境变量或 shell 变量中。
在这种情况下,常见的建议是使用公钥身份验证。
我认为,如果不了解您的脚本,就不可能想出解决方法。
You don't mention the svn+ssh implementation the script uses, but my guess is that the problem is this:
SSH clients tend to ask for passwords directly from the terminal. Password prompts often don't read from stdin, so you can't redirect input. For example, the OpenSSH client does it that way. It is designed that way to prevent users from doing insecure things - like storing passwords in files, environment variables or shell variables.
The common recommandation in this situation is to use public key authentication.
Without knowing your script, it will not be possible to come up with a workaround I think.