Re: [Tutor] execute an OS command, get the output

2006-03-12 Thread w chun
be the cause - ypou aren't acting like the shell does. > > But aws I say thats just a guess based on a quick scim of your port. > > Alan G. > > - Original Message ----- > From: "w chun" <[EMAIL PROTECTED]> > To: > Sent: Sunday, March 12, 2006 3:37 A

Re: [Tutor] execute an OS command, get the output

2006-03-12 Thread Alan Gauld
quot;w chun" <[EMAIL PROTECTED]> To: Sent: Sunday, March 12, 2006 3:37 AM Subject: Re: [Tutor] execute an OS command, get the output ok, while we're on the subject, i thought i should ask a question for once(!). it's been awhile since i played with pipes, and i ran into this problem

Re: [Tutor] execute an OS command, get the output

2006-03-12 Thread Alan Gauld
> Just for the heack of it, I wrote a tiny Python echo program, and > interposed it in the pipe between the strings and grep command: > > while 1: > line = raw_input() > print line > > The command line now looks like this: > >> strings 3193.DAT | python echo.py | grep Newsgroups: |

Re: [Tutor] execute an OS command, get the output

2006-03-12 Thread Alan Gauld
> I gotta admit, this took me by surprise, too, but my guess is that once > the head command is done, it closes the pipe it's reading from, which is > being filled by grep; grep takes the hint and terminates, closing the pipe > it's reading from, which is being filled by strings; and strings takes

Re: [Tutor] execute an OS command, get the output

2006-03-11 Thread w chun
ok, while we're on the subject, i thought i should ask a question for once(!). it's been awhile since i played with pipes, and i ran into this problem on the same day as this post! if i'm in the shell and playing with a 2-way game with the 'tr' command like so: $ tr '[a-z]' '[A-Z]' us US ca CA d

Re: [Tutor] execute an OS command, get the output

2006-03-11 Thread Terry Carroll
On Sat, 11 Mar 2006, Terry Carroll wrote: > Just for the heack of it, I wrote a tiny Python echo program, and > interposed it in the pipe between the strings and grep command: > > while 1: > line = raw_input() > print line > > The command line now looks like this: > > strings 3

Re: [Tutor] execute an OS command, get the output

2006-03-11 Thread Terry Carroll
On Sat, 11 Mar 2006, Terry Carroll wrote: > I gotta admit, this took me by surprise, too, but my guess is that once > the head command is done, it closes the pipe it's reading from, which is > being filled by grep; grep takes the hint and terminates, closing the pipe > it's reading from, which

Re: [Tutor] execute an OS command, get the output

2006-03-11 Thread Terry Carroll
On Sat, 11 Mar 2006, Alan Gauld wrote: > But surely the string command will take just as long to run regardless > of whether you use pipes or read the output into Python? Surely it will! Except that it doesn't. > Are ytou saying that running strings on its own takes 10 minutes but > running it

Re: [Tutor] execute an OS command, get the output

2006-03-11 Thread Alan Gauld
>> But in this case I'd use Pytthon to search for the string and get the >> last 10 entries rather than grep/head... > > That was my initial thought, but the files are 1-3 gigabytes. The string > command takes 10-15 minutes to get through a file. I've been using the > pipe sequence manually, so

Re: [Tutor] execute an OS command, get the output

2006-03-11 Thread Terry Carroll
On Sat, 11 Mar 2006, Alan Gauld wrote: > Take a look at the OS topic in my tutorial. The process control section > covers all of these calls and explains their differences. It also points out > that the latter is intended to replace all the others and shows examples. Excellent; I'll check it out.

Re: [Tutor] execute an OS command, get the output

2006-03-11 Thread Alan Gauld
> 1) the os.system module > 2a-d) os.popen, and popen2 popen3 and popen4 > 3) the popen2 module > 4) the subprocess module Take a look at the OS topic in my tutorial. The process control section covers all of these calls and explains their differences. It also points out that the latter is intende

Re: [Tutor] execute an OS command, get the output

2006-03-10 Thread Terry Carroll
On Fri, 10 Mar 2006, [ISO-8859-1] Hugo Gonz?lez Monteverde wrote: > Looks like you are looking for the commands module, it provides: > > getstatusoutput( cmd) > > getoutput( cmd) > > getstatus( file) > > > Which do exactly what tou want. Take a look at the docs at: > > http://python.active-v

Re: [Tutor] execute an OS command, get the output

2006-03-10 Thread Hugo González Monteverde
Hi Terry, > abc = executeit(commandline)or > executeit(commandline, abc) > Looks like you are looking for the commands module, it provides: getstatusoutput( cmd) getoutput( cmd) getstatus( file) Which do exactly what tou want. Take a look at the docs at: http://python.active-ve

[Tutor] execute an OS command, get the output

2006-03-10 Thread Terry Carroll
I need to execute a command and capture the stdout output. I'm overwhelmed by the plethora of means that Python offers to do something like this, and don't know which, if any, is most applicable: 1) the os.system module 2a-d) os.popen, and popen2 popen3 and popen4 3) the popen2 module 4) the subp