re module help

Ganesh Kumar bugcy013 at
Mon Jan 9 04:11:21 EST 2012

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()

            return results

## output [('00:15:83:3D:0A:57', 'phone', '1')]
please guide me. with out file creating, to archive required output.

Did I learn something today? If not, I wasted it.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list