0
아래 dialgoue를 자동화하려고합니다. 나는 입력 한 내용에 첫 번째 암호가 필요하다고 생각하지 않는다. 나는 힘든 시간을 보내고 pexpect를 얻으려고 노력하고 있습니다.pexpect를 사용하여 openssl req -new -key를 자동화하십시오. server.key -out server.csr
다음import pexpect
child = pexpect.spawn ('openssl req -new -key server.key -out server.csr')
child.expect ('key*')
child.sendline ('YYYY')
child.expect ("Country Name (2 letter code) [AU]:")
child.sendline ('US')
child.expect ("State or Province Name (full name) [Some-State]:")
child.sendline ('HI')
child.expect ("Locality Name (eg, city) []:")
child.sendline ('US')
child.expect ("Organization Name (eg, company) [Internet Widgits Pty Ltd]:")
child.sendline ('US')
child.expect ("Organizational Unit Name (eg, section) []:")
child.sendline ('US')
child.expect ("Common Name (e.g. server FQDN or YOUR name) []:")
child.sendline ('US')
child.expect ("Email Address []:")
child.sendline ('US')
child.expect ("A challenge password []:")
child.sendline ("yy")
child.expect ("An optional company name []:")
child.sendline ("yy")
child.expect(pexpect.EOF)
내 오류입니다 :
challenge password []:
An optional company name []:
[email protected]:/home/ubuntu# clear
[email protected]:/home/ubuntu# python vv.py
Traceback (most recent call last):
File "vv.py", line 5, in <module>
child.expect ("Country Name (2 letter code) [AU]:")
File "/usr/local/lib/python2.7/dist-packages/pexpect-2.4-py2.7.egg/pexpect.py", line 1316, in expect
return self.expect_list(compiled_pattern_list, timeout, searchwindowsize)
File "/usr/local/lib/python2.7/dist-packages/pexpect-2.4-py2.7.egg/pexpect.py", line 1330, in expect_list
return self.expect_loop(searcher_re(pattern_list), timeout, searchwindowsize)
File "/usr/local/lib/python2.7/dist-packages/pexpect-2.4-py2.7.egg/pexpect.py", line 1401, in expect_loop
raise EOF (str(e) + '\n' + str(self))
pexpect.EOF: End Of File (EOF) in read_nonblocking(). Exception style platform.
<pexpect.spawn object at 0x2083850>
version: 2.4 ($Revision: 516 $)
command: /usr/bin/openssl
args: ['/usr/bin/openssl', 'req', '-new', '-key', 'server.key', '-out', 'server.csr']
searcher: searcher_re:
0: re.compile("Country Name (2 letter code) [AU]:")
buffer (last 100 chars):
before (last 100 chars): p_enc.c:539:
140006640854688:error:0906A065:PEM routines:PEM_do_header:bad decrypt:pem_lib.c:476:
after: <class 'pexpect.EOF'>
match: None