[Tutor] execute an OS command, get the output

Alan Gauld alan.gauld at freenet.co.uk
Sat Mar 11 23:56:33 CET 2006


>> 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 I know it works, and only takes a second or two
> to run.

But surely the string command will take just as long to run regardless of 
whether
you use pipes or read the output into Python? Are ytou saying that running
strings on its own takes 10  minutes but running it in a pipe takes only a 
few
seconds? What happens if you redirect the strings output to a file instead 
of
a pipe - MS DOS terminal windows are notoriously slow, it could be the
display update thats taking the trime... Just a suggestion. But 3GB files 
will
take a while on any system!

> The Python program is for my own use, so I don't have to worry about
> whether and where string/grep/head are installed.

Whatever works for you! :-)

Alan G. 



More information about the Tutor mailing list