How do I enable regex in tn.read_until ()?
import telnetlib
tn = telnetlib.Telnet(IP)
tn.read_until("abcd login: ") --> This is only to match a particular pattern
Can a generic template be included in tn.read_until()
? Ex: the invitation can be "xyz login: " , "abcd login: "
, etc.
In regex, we use re.match('(.*)login: ',prompt)
. But I don't think so it works in tn.read_until()
, because the parameter it expects itself is a template. Is there a way to handle this?
+3
source to share