469,592 Members | 1,674 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,592 developers. It's quick & easy.

Getting the result of a process after exec*()

Hi,

I am trying to write a Python script that takes a ZIP file from a web
form (using CGI) and uses either of the UN*X unzip, gunzip, tar,
bunzip2 utilities to expand it.

I can use Python to save the script to disk; but processing it is
another matter. If for example I have received a *.tar.gz file, I need
to first pass it through gunzip; then through the tar utility. I also
want to process the resulting directory.

The problem for me is this: once an external process is called via
exec*() the script has effectively fulfilled its task. Is there any
way one can process a file with an external process and continue
further processing in Python; /once the external processing is
completed/?

Many thanks,

Andrew

Aug 17 '07 #1
2 1489
On 8/17/07, AndrewTK <at**********@gmail.comwrote:
The problem for me is this: once an external process is called via
exec*() the script has effectively fulfilled its task. Is there any
way one can process a file with an external process and continue
further processing in Python; /once the external processing is
completed/?
Assuming you're looking at the docs for the os module, instead of the
exec*() functions, check out the spawn*() functions, or, to use a
subshell, system(). Better yet, take a look at the subprocess module:
http://docs.python.org/lib/module-subprocess.html

-Miles
Aug 17 '07 #2
On 17 Sie, 16:33, AndrewTK <atkedzier...@gmail.comwrote:
Hi,

I am trying to write a Python script that takes a ZIP file from a web
form (using CGI) and uses either of the UN*X unzip, gunzip, tar,
bunzip2 utilities to expand it.

I can use Python to save the script to disk; but processing it is
another matter. If for example I have received a *.tar.gz file, I need
to first pass it through gunzip; then through the tar utility. I also
want to process the resulting directory.

The problem for me is this: once an external process is called via
exec*() the script has effectively fulfilled its task. Is there any
way one can process a file with an external process and continue
further processing in Python; /once the external processing is
completed/?

Many thanks,

Andrew
Hi Andrew,

Have You got some kind of requirement for using exec*() and calling
system gunzip etc?
I'd do It with urllib2 module (to download the file) and tarfile
module for extracting the *.tag.gz archive.

Cheers,
Marek

Aug 18 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by uwnewsgroup | last post: by
5 posts views Thread by Toby Donaldson | last post: by
8 posts views Thread by Mario Pranjic | last post: by
8 posts views Thread by mandydhaliwal | last post: by
10 posts views Thread by scoonie999 | last post: by
reply views Thread by suresh191 | last post: by
4 posts views Thread by guiromero | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.