Python Forum
Not able to read the text using pexpect/expect
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Not able to read the text using pexpect/expect
#7
(Jan-07-2022, 06:34 PM)Bipinjohnson Wrote: Also in the error message what are those extra characters (\x1b[2J\x1b[1dEnable QSE API? (Y/n) )?
These are probably ANSI terminal escape sequences. Never mind about them, it's a long story.

My suggestion was to shorten the expect string in line 4:
return_val=child.expect(["Enable QSE API"])
This should be enough to recognize the line. If it works you should also strip all characters that activate regular expressions from line 12. Oh and make it also a list by adding square brackets, otherwise the return code may not be zero.
And also: Are you sure a timeout of 3 seconds is sufficient? What happens if you leave the timout default (30)?
Reply


Messages In This Thread
RE: Not able to read the text using pexpect/expect - by ibreeden - Jan-07-2022, 07:08 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Reading and storing a line of output from pexpect child eagerissac 1 4,327 Feb-20-2024, 05:51 AM
Last Post: ayoshittu
  Read text file, modify it then write back Pavel_47 5 1,695 Feb-18-2023, 02:49 PM
Last Post: deanhystad
  read a text file, find all integers, append to list oldtrafford 12 3,740 Aug-11-2022, 08:23 AM
Last Post: Pedroski55
  Use pexpect to send user input alisha17 0 1,941 May-10-2022, 02:44 AM
Last Post: alisha17
  Sudden Problem with pexpect gw1500se 3 2,460 Nov-19-2021, 11:21 PM
Last Post: bowlofred
  How to use pexpect in python? tiho_bg 1 1,562 Oct-30-2021, 02:50 PM
Last Post: Yoriz
  [SOLVED] Read text file from some point till EOF? Winfried 1 2,002 Oct-10-2021, 10:29 PM
Last Post: Winfried
  Open and read multiple text files and match words kozaizsvemira 3 6,805 Jul-07-2021, 11:27 AM
Last Post: Larz60+
  Pexpect timesout before executing whole output eagerissac 0 1,537 Jun-23-2021, 03:30 AM
Last Post: eagerissac
  pexpect startup help korenron 2 3,529 Apr-27-2021, 07:23 AM
Last Post: korenron

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020