os.execl()

Roman Suzi rnd at onego.ru
Mon Aug 27 16:30:36 CEST 2001


On Mon, 27 Aug 2001, eli wrote:

> Hello,
> 
> 	I have a question about the ececl function from the os module. I was
> trying to write a script to untar a bunch of tarballs in a directory. The
> script looked like this
> 
> #!/usr/bin/env python
> 
> import os
> 
> os.system("ls *.gz > data_file")
> 
> tar_file = open("data_file"), "r")
> 
> tar_array = tar_file.readlines()

this is equivalent to:

import glob
tar_array = glob.glob("*.gz")
 
> for tarball in tar_array:
> 	os.execl("tar", "xzvf", tarball)

Why not just:

for tarball in tar_array:
      os.system("tar xzvf %s" % tarball)
 
> os.system("rm data_file")
> 
> 
> 
> 
> I was getting errors from the xzvf argument of tar during the first
> evecution of the loop. I'm pretty new to python so I don't knwo where to
> go from here. I would appreciate any help that you could give me. 
> 
> 																	Thanks,
> 																			eli
> 

Sincerely yours, Roman A.Suzi
-- 
 - Petrozavodsk - Karelia - Russia - mailto:rnd at onego.ru -
 






More information about the Python-list mailing list