Nov-19-2021, 03:49 PM
I have a script the uses pexpect that has been working for years (common story, right?) that suddenly is failing. When I run the command manually I first get a prompt for 'Username'. When I run the pexpect script I get a trace back.
I could probably figure this out if I understood what this traceback was telling me. Can someone interpret it for me? TIA.
1 2 |
proc = pexpect.spawn( '/usr/sbin/openvpn ' + config) proc.expect( 'Username:' ) |
Output:Traceback (most recent call last):
File "/usr/local/bin/VPNsudo.py", line 89, in <module>
proc=portOpen(configFile[useConfig])
File "/usr/local/bin/VPNsudo.py", line 47, in portOpen
proc.expect('Username:')
File "/usr/lib/python2.7/site-packages/pexpect.py", line 1311, in expect
return self.expect_list(compiled_pattern_list, timeout, searchwindowsize)
File "/usr/lib/python2.7/site-packages/pexpect.py", line 1325, in expect_list
return self.expect_loop(searcher_re(pattern_list), timeout, searchwindowsize)
File "/usr/lib/python2.7/site-packages/pexpect.py", line 1396, 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 0x7f5d9121c7d0>
version: 2.3 ($Revision: 399 $)
command: /usr/sbin/openvpn
args: ['/usr/sbin/openvpn']
searcher: searcher_re:
0: re.compile("Username:")
buffer (last 100 chars):
before (last 100 chars): d *BEFORE* this.
General Standalone Options:
--show-gateway : Show info about default gateway.
after: <class 'pexpect.EOF'>
match: None
match_index: None
exitstatus: None
flag_eof: True
pid: 6653
child_fd: 4
closed: False
timeout: 30
delimiter: <class 'pexpect.EOF'>
logfile: None
logfile_read: None
logfile_send: None
maxread: 2000
ignorecase: False
searchwindowsize: None
delaybeforesend: 0.05
delayafterclose: 0.1
delayafterterminate: 0.1
One thing I noticed is that the username prompt is in bold. (not sure if it has always been that way) I don't think that would cause the problem but I though I'd mention it. If that somehow changed the string so it doesn't match I would expect a different error.I could probably figure this out if I understood what this traceback was telling me. Can someone interpret it for me? TIA.