Re: [Tutor] Processing Linux command line output

2013-04-24 Thread bob gailer
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?

Re: [Tutor] Processing Linux command line output

2013-04-24 Thread Amit Saha
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

Re: [Tutor] Processing Linux command line output

2013-04-24 Thread Alan Gauld
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

Re: [Tutor] Processing Linux command line output

2013-04-24 Thread Prasad, Ramit
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

Re: [Tutor] Processing Linux command line output

2013-04-24 Thread Bill Campbell
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

[Tutor] Processing Linux command line output

2013-04-24 Thread Gareth Allen
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.