os.popen() v. os.popen2()? 
Author Message
 os.popen() v. os.popen2()?

I'm not sure I understand the difference here.  The documentation os
os.popen2() is pretty sparse.  For os.popen2(), it says that the command
is executed as a sub-process.  Isn't that also the case with os.popen()?
Under Unix, of course.

Thanks,
Ben

--

MAILER-DAEMON                                         (612) 321-9290 x101
Bitstream Underground                                   www.bitstream.net



Tue, 20 May 2003 03:00:00 GMT  
 os.popen() v. os.popen2()?

| I'm not sure I understand the difference here.  The documentation os
| os.popen2() is pretty sparse.  For os.popen2(), it says that the command
| is executed as a sub-process.  Isn't that also the case with os.popen()?
| Under Unix, of course.

Yes.

popen2()'s main feature is that it opens more pipes.  Its biggest
difference though is its python implementation, where the popen()
function calls the host platform's popen(3).  It's new in the os
module, which could account for the lack of documentation, but you
can look at the source in the popen2.py module.

One difference having to do with the subprocess is that popen2()
doesn't always invoke the shell to process the command, where
popen() always does.  Depending on the circumstances, the shell's
interpretation of the command can be a liability, so popen2() may
be attractive even if you want only one pipe.




Tue, 20 May 2003 03:00:00 GMT  
 os.popen() v. os.popen2()?

Quote:

> popen2()'s main feature is that it opens more pipes.  Its biggest
> difference though is its Python implementation, where the popen()
> function calls the host platform's popen(3).  It's new in the os
> module, which could account for the lack of documentation, but you
> can look at the source in the popen2.py module.

There is also some platform (and Python version) variation here - with
Python 2.0 under Windows, os.popen() no longer uses the host
platform's popen() (as did Python 1.5.2), but all the os.popen* calls
use the native Win32 API to create and manage the child process, the
code having been incorporated from what was previously available as
the win32pipe module from the win32all package.

--
-- David
--
/-----------------------------------------------------------------------\

  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 C{*filter*}Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



Tue, 20 May 2003 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. os.popen() vs os.system()

2. Using os.system and os.popen from pythonwin under Windows NT

3. os.system/os.popen ultrasparc

4. Blocking ctrl-c to os.popen() or os.system()

5. os._exit(), os.kill(os.getpid(), 9)

6. os.popen2

7. os.popen2() test croaks on python 1.5.2, Solaris 2.6

8. os.popen2 :URGENT

9. SF Bug #602245: os.popen() negative error code IOError

10. euid/egid eaten up by os.popen

11. euid/egid eaten up by os.popen

12. Python 2.2.1: os.popen() bug?

 

 
Powered by phpBB® Forum Software