从命令行填充密码的脚本
我有一个从 php (exec())
调用的命令:
openssl pkcs12 -export -in cert.pem -inkey key.pem -out cred.p12
然后我需要插入密码两次
Enter Export Password:
Verifying - Enter Export Password:
,我需要脚本来填充密码输入,因为 exec() 只会执行该命令,但不会插入密码两次。你知道我该怎么做吗?
I have this command that I am calling from php (exec())
:
openssl pkcs12 -export -in cert.pem -inkey key.pem -out cred.p12
and then I need to insert password twice
Enter Export Password:
Verifying - Enter Export Password:
I need script that will fill the password inputs, because exec()
will only do that command, but not insert password twice. Do you have any idea how should I do it?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 php 中,真正的双向 shell 并不容易,但在这种情况下,您可以仅使用换行符来模拟 Enter 键。
exec("Command\nPassword\nPassword");
对于真正的双向(读和写)可能性,您需要查看
proc_open()
。如果您不需要返回输出,您可以在
w
模式下使用更简单的popen()
,但您需要验证您的命令是否已成功运行,因为您不会得到输出或错误代码。A true bi-directional shell is not easy in php, but in this case you can just use a newline to simulate an enter press.
exec("Command\nPassword\nPassword");
For a true bi-directional (read & write) possibility you will need to look at
proc_open()
.If you do not need the return output you can use the far easier
popen()
inw
mode, but you'll need to verify that your command has successfully run because you won't get output or error codes back.