On 4/24/2013 6:03 PM, Gareth Allen wrote:
Hi all,
I'm trying to get the output of a command and split it into a list
that I can process. What is the best way to go about doing this? In
bash I would use tools like grep, sed awk etc.
Why do it in Python, given you already have a bash solution?
Hi Gareth,
On Thu, Apr 25, 2013 at 8:03 AM, Gareth Allen wrote:
> Hi all,
>
> I'm trying to get the output of a command and split it into a list that I
> can process. What is the best way to go about doing this? In bash I would
> use tools like grep, sed awk etc.
>
> Here's an example:
>
> ifcon
On 24/04/13 23:03, Gareth Allen wrote:
I'm trying to get the output of a command
The subprocess module is the officially endorsed way of doing that
nowadays. The docs show many use cases depending on what you need.
That will let you captiure the output as a set of strings.
and split it int
Gareth Allen wrote:
> Hi all,
>
> I'm trying to get the output of a command and split it into a list that I can
> process. What is the
> best way to go about doing this? In bash I would use tools like grep, sed awk
> etc.
>
> Here's an example:
>
> ifconfig
>
> lo Link encap:Local Loo
On Thu, Apr 25, 2013, Gareth Allen wrote:
>
> Hi all,
> I'm trying to get the output of a command and split it into a list that
> I can process. What is the best way to go about doing this? In bash I
> would use tools like grep, sed awk etc.
The old way to do this uses os.popen
import os
Hi all,
I'm trying to get the output of a command and split it into a list that I
can process. What is the best way to go about doing this? In bash I would
use tools like grep, sed awk etc.
Here's an example:
ifconfig
loLink encap:Local Loopback
inet addr:127.0.0.1 Mask:255.