I've written a program that tests ISDN dial backup at 1,000 locations. I've
broken up the logic into server functions within a threading class (i.e.
logon, get interfaces, get dial string, etc.). At 999 locations, the
following code extract the first of three dial strings:

   def GetDialString(self):
       """ This function extracts the dial string."""
       self.tn.write("term len 0\n")
       self.tn.expect([self.host.upper() + "#"], 7)
       self.tn.write("sh dialer | i Default\n")
       self.data = self.tn.read_until(self.host.upper() + "#", 7)
       print self.data
       match = re.search("\d\d\d\d\d\d\d\d\d\d\d+", self.data)
       if match is not None:
           rc = match.group()
       else:
           rc = "missing"
       return rc

One location doesn't return it's dial string. In Idle, the output is:

print data
sh dialer | i Default
17002111000              1          0    8w2d           successful   Default
17002111002              0          0    never                   -   Default
17002111001              1          0    never                   -   Default
J07MR3640#

The "print data" statement yields:

term len 0
J07MR3640#

I've run a packet capture and I see the data coming back every time. I don't
understand why it works fine for 999 out of 1,000 locations. Any
suggestions?
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to