[BangPypers] re module help
Noufal Ibrahim
noufal at nibrahim.net.in
Mon Jan 9 04:15:33 EST 2012
Ganesh Kumar <bugcy013 at gmail.com> writes:
> 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.
You should use the subprocess module to deal with external commands.
>>> import subprocess
>>> s = subprocess.Popen(["head", "/etc/hosts"], stdout = subprocess.PIPE)
>>> hosts_head = s.stdout.read()
>>> print hosts_head
127.0.0.1 localhost
[...]
Use that get your output and then parse it with the regexp.
--
~noufal
http://nibrahim.net.in
The best cure for insomnia is to get a lot of sleep. -W. C. Fields
More information about the Python-list
mailing list