Re: [Tutor] using subprocess to export files in bash

2012-05-08 Thread Rogelio
On Tue, May 8, 2012 at 11:06 AM, David Abbott wrote: > I have used this before; > > def uptime_report(): >    """Generate uptime""" >    p = subprocess.Popen("uptime > /tmp/uptime.txt", >            shell=True, stdout=subprocess.PIPE) >    return p.stdout.readlines() > > That was from python 2.6

Re: [Tutor] using subprocess to export files in bash

2012-05-08 Thread David Abbott
On Tue, May 8, 2012 at 1:41 PM, Alan Gauld wrote: > On 08/05/12 15:18, Rogelio wrote: >> >> While reading the subprocess documentation, I found a great example on >> how to call commands with a PIPE >> >> http://docs.python.org/library/subprocess.html >> >> ** >> output=`dm

Re: [Tutor] using subprocess to export files in bash

2012-05-08 Thread Alan Gauld
On 08/05/12 15:18, Rogelio wrote: While reading the subprocess documentation, I found a great example on how to call commands with a PIPE http://docs.python.org/library/subprocess.html ** output=`dmesg | grep hda` # becomes p1 = Popen(["dmesg"], stdout=PIPE) p2 = Popen([

Re: [Tutor] using subprocess to export files in bash

2012-05-08 Thread BRAGA, Bruno
No idea why you would want to do that (looks more complicated in python than in bash, right?)... but: f = open("log.txt", "w") f.write(output) f.close() -- *Braga, Bruno* www.brunobraga.net bruno.br...@gmail.com On Wed, May 9, 2012 at 12:18 AM, Rogelio wrote: > While reading the subprocess do

[Tutor] using subprocess to export files in bash

2012-05-08 Thread Rogelio
While reading the subprocess documentation, I found a great example on how to call commands with a PIPE http://docs.python.org/library/subprocess.html ** output=`dmesg | grep hda` # becomes p1 = Popen(["dmesg"], stdout=PIPE) p2 = Popen(["grep", "hda"], stdin=p1.stdout, std