Piet van Oostrum wrote:
Scott David Daniels (SDD) schreef:
...
SDD> Or even:
SDD> proc = subprocess.Popen(['ls','-la'], stdout=subprocess.PIPE)
SDD> with gzip.open(filename, 'w') as dest:
SDD> for line in iter(proc.stdout, ''):
SDD> f.write(line)
If it would work.
> Scott David Daniels (SDD) schreef:
>SDD> Piet van Oostrum wrote:
>>> ...
>>> f = gzip.open(filename, 'w')
>>> proc = subprocess.Popen(['ls','-la'], stdout=subprocess.PIPE)
>>> while True:
>>> line = proc.stdout.readline()
>>> if not line: break
>>> f.write(line)
>>> f.close()
>SDD> Or even
Piet van Oostrum wrote:
...
f = gzip.open(filename, 'w')
proc = subprocess.Popen(['ls','-la'], stdout=subprocess.PIPE)
while True:
line = proc.stdout.readline()
if not line: break
f.write(line)
f.close()
Or even:
proc = subprocess.Popen(['ls','-la'], stdout=subprocess.PIPE)
> Iwan Vosloo (IV) wrote:
>IV> Hi there,
>IV> We tried to gzip the output of a shell command, but this results in a
>IV> strange error: the resulting file seems to be the concatenation of the
>IV> plaintext file with the zipped content.
>IV> For example:
>IV> f = gzip.open(filename, 'w')
>I