在 运行 cmd 命令之后,是否有任何功能可以在 python 中自动插入用户输入?
Is there any function for inserting user input automatically in python after running a cmd command?
我正在尝试 运行 python 中的 openssl 命令。问题是每次我 运行 它要求输入密码的命令。当要求输入密码时,是否有任何函数可以放入 i、j、k、l 变量?密码应介于 0000-9999 之间。这是我的代码:
from pynput.keyboard import Key, Controller
import os
import subprocess
keyboard=Controller()
for i in range(10):
for j in range(10):
for k in range(10):
for l in range(10):
os.system('openssl rsa -in bob.prv -pubout -out bob.pub')
print(i)
print(j)
print(k)
print(l)
keyboard.press('enter')
keyboard.release('enter')
避免提示密码的一种方法是使用 passphrase
参数作为 OpenSSL 命令的一部分。有多种来源可以传递密码,如文件、环境变量等。
对于 openssl rsa
命令,有两个密码参数:-passin arg
& -passout arg
。
更多详情请参考:https://www.openssl.org/docs/manmaster/man1/rsa.html
有关如何传递密码短语参数的详细信息,请参阅 密码短语选项 部分:https://www.openssl.org/docs/manmaster/man1/openssl.html
我正在尝试 运行 python 中的 openssl 命令。问题是每次我 运行 它要求输入密码的命令。当要求输入密码时,是否有任何函数可以放入 i、j、k、l 变量?密码应介于 0000-9999 之间。这是我的代码:
from pynput.keyboard import Key, Controller
import os
import subprocess
keyboard=Controller()
for i in range(10):
for j in range(10):
for k in range(10):
for l in range(10):
os.system('openssl rsa -in bob.prv -pubout -out bob.pub')
print(i)
print(j)
print(k)
print(l)
keyboard.press('enter')
keyboard.release('enter')
避免提示密码的一种方法是使用 passphrase
参数作为 OpenSSL 命令的一部分。有多种来源可以传递密码,如文件、环境变量等。
对于 openssl rsa
命令,有两个密码参数:-passin arg
& -passout arg
。
更多详情请参考:https://www.openssl.org/docs/manmaster/man1/rsa.html
有关如何传递密码短语参数的详细信息,请参阅 密码短语选项 部分:https://www.openssl.org/docs/manmaster/man1/openssl.html