Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #18702

Re: [BangPypers] re module help

From Noufal Ibrahim <noufal@nibrahim.net.in>
Subject Re: [BangPypers] re module help
References <CAJzooYf1F6qavSyuQtvO6eMjDOSq2dzdTqLiTmng3cAn2JLYzg@mail.gmail.com>
Date 2012-01-09 14:45 +0530
Newsgroups comp.lang.python
Message-ID <mailman.4543.1326100744.27778.python-list@python.org> (permalink)

Show all headers | View raw


Ganesh Kumar <bugcy013@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

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

Re: [BangPypers] re module help Noufal Ibrahim <noufal@nibrahim.net.in> - 2012-01-09 14:45 +0530

csiph-web