Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the matching print? #41

Open
yunpengb opened this issue Oct 9, 2020 · 1 comment
Open

How to get the matching print? #41

yunpengb opened this issue Oct 9, 2020 · 1 comment

Comments

@yunpengb
Copy link

yunpengb commented Oct 9, 2020

Describe the bug
I make a test on win10, try to send a few commands and get their feedback printing.
code like this

import wexpect
import re

cmdPrompt = re.compile('[A-Z]\:.+>')
p = wexpect.spawn('cmd.exe')
p.expect(cmdPrompt, timeout = 50)

p.sendline('VER')
p.expect(cmdPrompt, timeout = 50)
print('========1 VER')
print(p.before)
print(p.after)

p.sendline('VOL')
p.expect(cmdPrompt, timeout = 50)
print('========2 VOL')
print(p.before)
print(p.after)

p.sendline('ECHO 1')
p.expect(cmdPrompt, timeout = 50)
print('========3 ECHO 1')
print(p.before)
print(p.after)

To Reproduce
run this script on win10

Expected behavior
every step send the command, I can get the matching feedback printing

Screenshots
Now seems the feedback printing is always to be showing later
The execution results are as follows

D:\CODE>python test.py
========1 VER
D:\CODE>
========2 VOL
VER

Microsoft Windows [Version 10.0.18363.1110]

D:\CODE>
========3 ECHO 1

D:\CODE>
D:\CODE>

Environment:

  • [windows version] win10 10.0.18363.1110
  • [Python version] Python 3.8.5
  • [wexpect version] wexpect 4.0.0
@raczben
Copy link
Owner

raczben commented Oct 11, 2020

I cannot reproduce:

D:\wexpect_test>python i41.py
========1 VER
VER

Microsoft Windows [Version 10.0.19041.508]


D:\wexpect_test>
========2 VOL
VOL
 Volume in drive D is DATA
 Volume Serial Number is 1234-5678


D:\wexpect_test>
========3 ECHO 1
ECHO 1
1


D:\wexpect_test>

D:\wexpect_test>

It seems that the cmdPrompt matches something else in your system.

Please try to replace the re.compile('[A-Z]\:.+>') expression to your exact prompt: cmdPrompt='D:\\CODE>'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants