os.execl()

Steve Holden sholden at holdenweb.com
Mon Aug 27 11:14:32 EDT 2001


"eli" <eli at udel.edu> wrote in message
news:20010827.094906.1398295499.2106 at udel.edu...
> 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()
>
> for tarball in tar_array:
> os.execl("tar", "xzvf", 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.
>
Besides the other excellent advice you've had about this, also note that
readlines() retains the line terminators on the ines it has read, so if you
don't strip these off you may find that they are not recognised as filenames
when passed as arguments to execv() and spawnv().

regards
 Steve

--
http://www.holdenweb.com/








More information about the Python-list mailing list