Hi Guys, I have created regular expression with os modules, I have created file sdptool to match the regular expression pattern, will print the result. I want without creating file how to get required output, I tried but i didn't get output correctly, over stream.
#! /usr/bin/python import os,re def scan(): cmd = "sdptool -i hci0 search OPUSH > sdptool" fp = os.popen(cmd) results = [] l = open("sdptool").read() pattern = r"^Searching for OPUSH on (\w\w(:\w\w)+).*?Channel: (\d+)" r = re.compile(pattern, flags=re.MULTILINE|re.DOTALL) while True: for match in r.finditer(l): g = match.groups() results.append((g[0],'phone',g[2])) return results ## output [('00:15:83:3D:0A:57', 'phone', '1')] http://dpaste.com/684335/ please guide me. with out file creating, to archive required output. Did I learn something today? If not, I wasted it. _______________________________________________ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers