Linux server.nvwebsoft.co.in 3.10.0-1160.114.2.el7.x86_64 #1 SMP Wed Mar 20 15:54:52 UTC 2024 x86_64
Apache
: 162.240.12.249 | : 3.15.214.238
202 Domain
8.1.31
nbspublicschool
www.github.com/MadExploits
Terminal
AUTO ROOT
Adminer
Backdoor Destroyer
Linux Exploit
Lock Shell
Lock File
Create User
CREATE RDP
PHP Mailer
BACKCONNECT
UNLOCK SHELL
HASH IDENTIFIER
CPANEL RESET
CREATE WP USER
README
+ Create Folder
+ Create File
/
usr /
share /
doc /
python-docs-2.7.5 /
html /
library /
[ HOME SHELL ]
Name
Size
Permission
Action
2to3.html
49.27
KB
-rw-r--r--
__builtin__.html
10.26
KB
-rw-r--r--
__future__.html
13.79
KB
-rw-r--r--
__main__.html
7.05
KB
-rw-r--r--
_winreg.html
59.21
KB
-rw-r--r--
abc.html
23.9
KB
-rw-r--r--
aepack.html
13.16
KB
-rw-r--r--
aetools.html
14.91
KB
-rw-r--r--
aetypes.html
18.88
KB
-rw-r--r--
aifc.html
22.4
KB
-rw-r--r--
al.html
17.34
KB
-rw-r--r--
allos.html
33.72
KB
-rw-r--r--
anydbm.html
16.33
KB
-rw-r--r--
archiving.html
9.26
KB
-rw-r--r--
argparse.html
237.62
KB
-rw-r--r--
array.html
29.29
KB
-rw-r--r--
ast.html
34.98
KB
-rw-r--r--
asynchat.html
31.43
KB
-rw-r--r--
asyncore.html
36.51
KB
-rw-r--r--
atexit.html
16.8
KB
-rw-r--r--
audioop.html
31.36
KB
-rw-r--r--
autogil.html
8.19
KB
-rw-r--r--
base64.html
19.67
KB
-rw-r--r--
basehttpserver.html
34.04
KB
-rw-r--r--
bastion.html
11.04
KB
-rw-r--r--
bdb.html
36.68
KB
-rw-r--r--
binascii.html
20.67
KB
-rw-r--r--
binhex.html
10.58
KB
-rw-r--r--
bisect.html
23.24
KB
-rw-r--r--
bsddb.html
26.43
KB
-rw-r--r--
bz2.html
26.08
KB
-rw-r--r--
calendar.html
37.79
KB
-rw-r--r--
carbon.html
48.94
KB
-rw-r--r--
cd.html
27.96
KB
-rw-r--r--
cgi.html
49.92
KB
-rw-r--r--
cgihttpserver.html
13.1
KB
-rw-r--r--
cgitb.html
11.41
KB
-rw-r--r--
chunk.html
14.66
KB
-rw-r--r--
cmath.html
25.63
KB
-rw-r--r--
cmd.html
26.09
KB
-rw-r--r--
code.html
24.58
KB
-rw-r--r--
codecs.html
100.64
KB
-rw-r--r--
codeop.html
14.84
KB
-rw-r--r--
collections.html
133.96
KB
-rw-r--r--
colorpicker.html
7.52
KB
-rw-r--r--
colorsys.html
11.04
KB
-rw-r--r--
commands.html
14.36
KB
-rw-r--r--
compileall.html
16.83
KB
-rw-r--r--
compiler.html
67.75
KB
-rw-r--r--
configparser.html
62.13
KB
-rw-r--r--
constants.html
12.83
KB
-rw-r--r--
contextlib.html
19.39
KB
-rw-r--r--
cookie.html
39.07
KB
-rw-r--r--
cookielib.html
83.82
KB
-rw-r--r--
copy.html
12.19
KB
-rw-r--r--
copy_reg.html
13.76
KB
-rw-r--r--
crypt.html
10.04
KB
-rw-r--r--
crypto.html
7.59
KB
-rw-r--r--
csv.html
67.37
KB
-rw-r--r--
ctypes.html
238.78
KB
-rw-r--r--
curses.ascii.html
22.29
KB
-rw-r--r--
curses.html
146.63
KB
-rw-r--r--
curses.panel.html
14.39
KB
-rw-r--r--
custominterp.html
7.62
KB
-rw-r--r--
datatypes.html
16.84
KB
-rw-r--r--
datetime.html
226.59
KB
-rw-r--r--
dbhash.html
15.48
KB
-rw-r--r--
dbm.html
12.07
KB
-rw-r--r--
debug.html
10.15
KB
-rw-r--r--
decimal.html
194.44
KB
-rw-r--r--
development.html
14.17
KB
-rw-r--r--
difflib.html
84.83
KB
-rw-r--r--
dircache.html
11.41
KB
-rw-r--r--
dis.html
69.95
KB
-rw-r--r--
distutils.html
8.05
KB
-rw-r--r--
dl.html
16.33
KB
-rw-r--r--
doctest.html
165.54
KB
-rw-r--r--
docxmlrpcserver.html
16.43
KB
-rw-r--r--
dumbdbm.html
14.02
KB
-rw-r--r--
dummy_thread.html
9.43
KB
-rw-r--r--
dummy_threading.html
8.37
KB
-rw-r--r--
easydialogs.html
30.55
KB
-rw-r--r--
email-examples.html
45.65
KB
-rw-r--r--
email.charset.html
26.8
KB
-rw-r--r--
email.encoders.html
11.86
KB
-rw-r--r--
email.errors.html
15.77
KB
-rw-r--r--
email.generator.html
20.77
KB
-rw-r--r--
email.header.html
26.92
KB
-rw-r--r--
email.html
44.24
KB
-rw-r--r--
email.iterators.html
11.52
KB
-rw-r--r--
email.message.html
63.16
KB
-rw-r--r--
email.mime.html
27.93
KB
-rw-r--r--
email.parser.html
30.45
KB
-rw-r--r--
email.util.html
24.46
KB
-rw-r--r--
errno.html
37.99
KB
-rw-r--r--
exceptions.html
56.13
KB
-rw-r--r--
fcntl.html
22.67
KB
-rw-r--r--
filecmp.html
22.3
KB
-rw-r--r--
fileformats.html
9.14
KB
-rw-r--r--
fileinput.html
24.28
KB
-rw-r--r--
filesys.html
10.2
KB
-rw-r--r--
fl.html
49.92
KB
-rw-r--r--
fm.html
11.91
KB
-rw-r--r--
fnmatch.html
14.58
KB
-rw-r--r--
formatter.html
34.06
KB
-rw-r--r--
fpectl.html
16.01
KB
-rw-r--r--
fpformat.html
10.59
KB
-rw-r--r--
fractions.html
22.61
KB
-rw-r--r--
framework.html
33.34
KB
-rw-r--r--
frameworks.html
7.14
KB
-rw-r--r--
ftplib.html
43.99
KB
-rw-r--r--
functions.html
183.14
KB
-rw-r--r--
functools.html
27.17
KB
-rw-r--r--
future_builtins.html
13.04
KB
-rw-r--r--
gc.html
25.75
KB
-rw-r--r--
gdbm.html
15.96
KB
-rw-r--r--
gensuitemodule.html
11.51
KB
-rw-r--r--
getopt.html
23.66
KB
-rw-r--r--
getpass.html
10.65
KB
-rw-r--r--
gettext.html
78.76
KB
-rw-r--r--
gl.html
22.09
KB
-rw-r--r--
glob.html
13.26
KB
-rw-r--r--
grp.html
10.49
KB
-rw-r--r--
gzip.html
18.99
KB
-rw-r--r--
hashlib.html
18.2
KB
-rw-r--r--
heapq.html
31.61
KB
-rw-r--r--
hmac.html
10.46
KB
-rw-r--r--
hotshot.html
18.65
KB
-rw-r--r--
htmllib.html
25.32
KB
-rw-r--r--
htmlparser.html
39.11
KB
-rw-r--r--
httplib.html
62.95
KB
-rw-r--r--
i18n.html
9.52
KB
-rw-r--r--
ic.html
17.17
KB
-rw-r--r--
idle.html
20.9
KB
-rw-r--r--
imageop.html
14.76
KB
-rw-r--r--
imaplib.html
51.99
KB
-rw-r--r--
imgfile.html
11.71
KB
-rw-r--r--
imghdr.html
11.3
KB
-rw-r--r--
imp.html
34.34
KB
-rw-r--r--
importlib.html
8.26
KB
-rw-r--r--
imputil.html
31.81
KB
-rw-r--r--
index.html
72.78
KB
-rw-r--r--
inspect.html
50.71
KB
-rw-r--r--
internet.html
24.87
KB
-rw-r--r--
intro.html
8.93
KB
-rw-r--r--
io.html
98.13
KB
-rw-r--r--
ipc.html
13.41
KB
-rw-r--r--
itertools.html
115.91
KB
-rw-r--r--
jpeg.html
12.74
KB
-rw-r--r--
json.html
67.04
KB
-rw-r--r--
keyword.html
7.68
KB
-rw-r--r--
language.html
11.03
KB
-rw-r--r--
linecache.html
10.59
KB
-rw-r--r--
locale.html
55.14
KB
-rw-r--r--
logging.config.html
63.36
KB
-rw-r--r--
logging.handlers.html
69.64
KB
-rw-r--r--
logging.html
95.64
KB
-rw-r--r--
mac.html
21.79
KB
-rw-r--r--
macos.html
14.76
KB
-rw-r--r--
macosa.html
12.96
KB
-rw-r--r--
macostools.html
15.52
KB
-rw-r--r--
macpath.html
7.76
KB
-rw-r--r--
mailbox.html
156.75
KB
-rw-r--r--
mailcap.html
13.21
KB
-rw-r--r--
markup.html
18.77
KB
-rw-r--r--
marshal.html
17.98
KB
-rw-r--r--
math.html
39.24
KB
-rw-r--r--
md5.html
13.97
KB
-rw-r--r--
mhlib.html
21.54
KB
-rw-r--r--
mimetools.html
19.25
KB
-rw-r--r--
mimetypes.html
28.39
KB
-rw-r--r--
mimewriter.html
15.02
KB
-rw-r--r--
mimify.html
13.36
KB
-rw-r--r--
miniaeframe.html
12.2
KB
-rw-r--r--
misc.html
6.87
KB
-rw-r--r--
mm.html
9.03
KB
-rw-r--r--
mmap.html
28.36
KB
-rw-r--r--
modulefinder.html
15.31
KB
-rw-r--r--
modules.html
8.46
KB
-rw-r--r--
msilib.html
52.43
KB
-rw-r--r--
msvcrt.html
19.37
KB
-rw-r--r--
multifile.html
24.3
KB
-rw-r--r--
multiprocessing.html
365.71
KB
-rw-r--r--
mutex.html
11.23
KB
-rw-r--r--
netdata.html
16.98
KB
-rw-r--r--
netrc.html
12.3
KB
-rw-r--r--
new.html
12.12
KB
-rw-r--r--
nis.html
10.64
KB
-rw-r--r--
nntplib.html
41.92
KB
-rw-r--r--
numbers.html
37.75
KB
-rw-r--r--
numeric.html
13.55
KB
-rw-r--r--
operator.html
82
KB
-rw-r--r--
optparse.html
222.56
KB
-rw-r--r--
os.html
214.25
KB
-rw-r--r--
os.path.html
38.34
KB
-rw-r--r--
ossaudiodev.html
41.5
KB
-rw-r--r--
othergui.html
9.08
KB
-rw-r--r--
parser.html
39.36
KB
-rw-r--r--
pdb.html
33.96
KB
-rw-r--r--
persistence.html
14.87
KB
-rw-r--r--
pickle.html
102.27
KB
-rw-r--r--
pickletools.html
10.63
KB
-rw-r--r--
pipes.html
18.01
KB
-rw-r--r--
pkgutil.html
25.11
KB
-rw-r--r--
platform.html
28.37
KB
-rw-r--r--
plistlib.html
17.03
KB
-rw-r--r--
popen2.html
25.43
KB
-rw-r--r--
poplib.html
22.32
KB
-rw-r--r--
posix.html
14.41
KB
-rw-r--r--
posixfile.html
19.76
KB
-rw-r--r--
pprint.html
29.92
KB
-rw-r--r--
profile.html
63.56
KB
-rw-r--r--
pty.html
9.48
KB
-rw-r--r--
pwd.html
11.43
KB
-rw-r--r--
py_compile.html
11.12
KB
-rw-r--r--
pyclbr.html
14.71
KB
-rw-r--r--
pydoc.html
11.48
KB
-rw-r--r--
pyexpat.html
71.53
KB
-rw-r--r--
python.html
12.27
KB
-rw-r--r--
queue.html
24.22
KB
-rw-r--r--
quopri.html
11.9
KB
-rw-r--r--
random.html
37.83
KB
-rw-r--r--
re.html
134.74
KB
-rw-r--r--
readline.html
28.24
KB
-rw-r--r--
repr.html
20.43
KB
-rw-r--r--
resource.html
26.48
KB
-rw-r--r--
restricted.html
11.65
KB
-rw-r--r--
rexec.html
37.41
KB
-rw-r--r--
rfc822.html
42.22
KB
-rw-r--r--
rlcompleter.html
13.51
KB
-rw-r--r--
robotparser.html
12.27
KB
-rw-r--r--
runpy.html
19.34
KB
-rw-r--r--
sched.html
18.54
KB
-rw-r--r--
scrolledtext.html
9.32
KB
-rw-r--r--
select.html
39.67
KB
-rw-r--r--
sets.html
36.92
KB
-rw-r--r--
sgi.html
9.71
KB
-rw-r--r--
sgmllib.html
30.77
KB
-rw-r--r--
sha.html
12.09
KB
-rw-r--r--
shelve.html
27.02
KB
-rw-r--r--
shlex.html
32.1
KB
-rw-r--r--
shutil.html
40.22
KB
-rw-r--r--
signal.html
31.14
KB
-rw-r--r--
simplehttpserver.html
18.41
KB
-rw-r--r--
simplexmlrpcserver.html
31.39
KB
-rw-r--r--
site.html
23.64
KB
-rw-r--r--
smtpd.html
12.46
KB
-rw-r--r--
smtplib.html
42.13
KB
-rw-r--r--
sndhdr.html
10.02
KB
-rw-r--r--
socket.html
106.34
KB
-rw-r--r--
socketserver.html
59.83
KB
-rw-r--r--
someos.html
15.11
KB
-rw-r--r--
spwd.html
10.33
KB
-rw-r--r--
sqlite3.html
139.5
KB
-rw-r--r--
ssl.html
65.62
KB
-rw-r--r--
stat.html
32.31
KB
-rw-r--r--
statvfs.html
10.6
KB
-rw-r--r--
stdtypes.html
260.4
KB
-rw-r--r--
string.html
106.65
KB
-rw-r--r--
stringio.html
18.81
KB
-rw-r--r--
stringprep.html
16.13
KB
-rw-r--r--
strings.html
14.93
KB
-rw-r--r--
struct.html
40.88
KB
-rw-r--r--
subprocess.html
84.91
KB
-rw-r--r--
sun.html
6.84
KB
-rw-r--r--
sunau.html
27.1
KB
-rw-r--r--
sunaudio.html
17.79
KB
-rw-r--r--
symbol.html
7.66
KB
-rw-r--r--
symtable.html
22.94
KB
-rw-r--r--
sys.html
98.7
KB
-rw-r--r--
sysconfig.html
23.84
KB
-rw-r--r--
syslog.html
17.92
KB
-rw-r--r--
tabnanny.html
10.63
KB
-rw-r--r--
tarfile.html
78.68
KB
-rw-r--r--
telnetlib.html
25.48
KB
-rw-r--r--
tempfile.html
29.42
KB
-rw-r--r--
termios.html
16.01
KB
-rw-r--r--
test.html
52.62
KB
-rw-r--r--
textwrap.html
27.25
KB
-rw-r--r--
thread.html
20.47
KB
-rw-r--r--
threading.html
76.69
KB
-rw-r--r--
time.html
56.93
KB
-rw-r--r--
timeit.html
36.27
KB
-rw-r--r--
tix.html
46.96
KB
-rw-r--r--
tk.html
23.64
KB
-rw-r--r--
tkinter.html
67.67
KB
-rw-r--r--
token.html
19.62
KB
-rw-r--r--
tokenize.html
18.45
KB
-rw-r--r--
trace.html
25.54
KB
-rw-r--r--
traceback.html
33.44
KB
-rw-r--r--
ttk.html
101.75
KB
-rw-r--r--
tty.html
9.06
KB
-rw-r--r--
turtle.html
211.74
KB
-rw-r--r--
types.html
27.59
KB
-rw-r--r--
undoc.html
23.16
KB
-rw-r--r--
unicodedata.html
18.55
KB
-rw-r--r--
unittest.html
202.85
KB
-rw-r--r--
unix.html
10.55
KB
-rw-r--r--
urllib.html
58.68
KB
-rw-r--r--
urllib2.html
100.58
KB
-rw-r--r--
urlparse.html
40.41
KB
-rw-r--r--
user.html
11.83
KB
-rw-r--r--
userdict.html
29.73
KB
-rw-r--r--
uu.html
11.03
KB
-rw-r--r--
uuid.html
28.19
KB
-rw-r--r--
warnings.html
46.6
KB
-rw-r--r--
wave.html
22.22
KB
-rw-r--r--
weakref.html
36.52
KB
-rw-r--r--
webbrowser.html
23.07
KB
-rw-r--r--
whichdb.html
8.85
KB
-rw-r--r--
windows.html
9.33
KB
-rw-r--r--
winsound.html
18.75
KB
-rw-r--r--
wsgiref.html
81.04
KB
-rw-r--r--
xdrlib.html
29.94
KB
-rw-r--r--
xml.dom.html
89.04
KB
-rw-r--r--
xml.dom.minidom.html
40.42
KB
-rw-r--r--
xml.dom.pulldom.html
12.71
KB
-rw-r--r--
xml.etree.elementtree.html
93.22
KB
-rw-r--r--
xml.html
16.49
KB
-rw-r--r--
xml.sax.handler.html
38.63
KB
-rw-r--r--
xml.sax.html
20.22
KB
-rw-r--r--
xml.sax.reader.html
39.09
KB
-rw-r--r--
xml.sax.utils.html
14.26
KB
-rw-r--r--
xmlrpclib.html
60.79
KB
-rw-r--r--
zipfile.html
53.14
KB
-rw-r--r--
zipimport.html
20.42
KB
-rw-r--r--
zlib.html
25.46
KB
-rw-r--r--
Delete
Unzip
Zip
${this.title}
Close
Code Editor : subprocess.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>17.1. subprocess — Subprocess management — Python 2.7.5 documentation</title> <link rel="stylesheet" href="../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../', VERSION: '2.7.5', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../_static/jquery.js"></script> <script type="text/javascript" src="../_static/underscore.js"></script> <script type="text/javascript" src="../_static/doctools.js"></script> <script type="text/javascript" src="../_static/sidebar.js"></script> <link rel="search" type="application/opensearchdescription+xml" title="Search within Python 2.7.5 documentation" href="../_static/opensearch.xml"/> <link rel="author" title="About these documents" href="../about.html" /> <link rel="copyright" title="Copyright" href="../copyright.html" /> <link rel="top" title="Python 2.7.5 documentation" href="../index.html" /> <link rel="up" title="17. Interprocess Communication and Networking" href="ipc.html" /> <link rel="next" title="17.2. socket — Low-level networking interface" href="socket.html" /> <link rel="prev" title="17. Interprocess Communication and Networking" href="ipc.html" /> <link rel="shortcut icon" type="image/png" href="../_static/py.png" /> <script type="text/javascript" src="../_static/copybutton.js"></script> </head> <body> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" accesskey="I">index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="socket.html" title="17.2. socket — Low-level networking interface" accesskey="N">next</a> |</li> <li class="right" > <a href="ipc.html" title="17. Interprocess Communication and Networking" accesskey="P">previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.5 documentation</a> » </li> <li><a href="index.html" >The Python Standard Library</a> »</li> <li><a href="ipc.html" accesskey="U">17. Interprocess Communication and Networking</a> »</li> </ul> </div> <div class="document"> <div class="documentwrapper"> <div class="bodywrapper"> <div class="body"> <div class="section" id="module-subprocess"> <span id="subprocess-subprocess-management"></span><h1>17.1. <a class="reference internal" href="#module-subprocess" title="subprocess: Subprocess management."><tt class="xref py py-mod docutils literal"><span class="pre">subprocess</span></tt></a> — Subprocess management<a class="headerlink" href="#module-subprocess" title="Permalink to this headline">¶</a></h1> <p class="versionadded"> <span class="versionmodified">New in version 2.4.</span></p> <p>The <a class="reference internal" href="#module-subprocess" title="subprocess: Subprocess management."><tt class="xref py py-mod docutils literal"><span class="pre">subprocess</span></tt></a> module allows you to spawn new processes, connect to their input/output/error pipes, and obtain their return codes. This module intends to replace several other, older modules and functions, such as:</p> <div class="highlight-python"><pre>os.system os.spawn* os.popen* popen2.* commands.*</pre> </div> <p>Information about how the <a class="reference internal" href="#module-subprocess" title="subprocess: Subprocess management."><tt class="xref py py-mod docutils literal"><span class="pre">subprocess</span></tt></a> module can be used to replace these modules and functions can be found in the following sections.</p> <div class="admonition-see-also admonition seealso"> <p class="first admonition-title">See also</p> <p class="last"><span class="target" id="index-0"></span><a class="pep reference external" href="http://www.python.org/dev/peps/pep-0324"><strong>PEP 324</strong></a> – PEP proposing the subprocess module</p> </div> <div class="section" id="using-the-subprocess-module"> <h2>17.1.1. Using the <a class="reference internal" href="#module-subprocess" title="subprocess: Subprocess management."><tt class="xref py py-mod docutils literal"><span class="pre">subprocess</span></tt></a> Module<a class="headerlink" href="#using-the-subprocess-module" title="Permalink to this headline">¶</a></h2> <p>The recommended approach to invoking subprocesses is to use the following convenience functions for all use cases they can handle. For more advanced use cases, the underlying <a class="reference internal" href="#subprocess.Popen" title="subprocess.Popen"><tt class="xref py py-class docutils literal"><span class="pre">Popen</span></tt></a> interface can be used directly.</p> <dl class="function"> <dt id="subprocess.call"> <tt class="descclassname">subprocess.</tt><tt class="descname">call</tt><big>(</big><em>args</em>, <em>*</em>, <em>stdin=None</em>, <em>stdout=None</em>, <em>stderr=None</em>, <em>shell=False</em><big>)</big><a class="headerlink" href="#subprocess.call" title="Permalink to this definition">¶</a></dt> <dd><p>Run the command described by <em>args</em>. Wait for command to complete, then return the <tt class="xref py py-attr docutils literal"><span class="pre">returncode</span></tt> attribute.</p> <p>The arguments shown above are merely the most common ones, described below in <a class="reference internal" href="#frequently-used-arguments"><em>Frequently Used Arguments</em></a> (hence the slightly odd notation in the abbreviated signature). The full function signature is the same as that of the <a class="reference internal" href="#subprocess.Popen" title="subprocess.Popen"><tt class="xref py py-class docutils literal"><span class="pre">Popen</span></tt></a> constructor - this functions passes all supplied arguments directly through to that interface.</p> <p>Examples:</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">subprocess</span><span class="o">.</span><span class="n">call</span><span class="p">([</span><span class="s">"ls"</span><span class="p">,</span> <span class="s">"-l"</span><span class="p">])</span> <span class="go">0</span> <span class="gp">>>> </span><span class="n">subprocess</span><span class="o">.</span><span class="n">call</span><span class="p">(</span><span class="s">"exit 1"</span><span class="p">,</span> <span class="n">shell</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span> <span class="go">1</span> </pre></div> </div> <div class="admonition warning"> <p class="first admonition-title">Warning</p> <p class="last">Invoking the system shell with <tt class="docutils literal"><span class="pre">shell=True</span></tt> can be a security hazard if combined with untrusted input. See the warning under <a class="reference internal" href="#frequently-used-arguments"><em>Frequently Used Arguments</em></a> for details.</p> </div> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">Do not use <tt class="docutils literal"><span class="pre">stdout=PIPE</span></tt> or <tt class="docutils literal"><span class="pre">stderr=PIPE</span></tt> with this function. As the pipes are not being read in the current process, the child process may block if it generates enough output to a pipe to fill up the OS pipe buffer.</p> </div> </dd></dl> <dl class="function"> <dt id="subprocess.check_call"> <tt class="descclassname">subprocess.</tt><tt class="descname">check_call</tt><big>(</big><em>args</em>, <em>*</em>, <em>stdin=None</em>, <em>stdout=None</em>, <em>stderr=None</em>, <em>shell=False</em><big>)</big><a class="headerlink" href="#subprocess.check_call" title="Permalink to this definition">¶</a></dt> <dd><p>Run command with arguments. Wait for command to complete. If the return code was zero then return, otherwise raise <a class="reference internal" href="#subprocess.CalledProcessError" title="subprocess.CalledProcessError"><tt class="xref py py-exc docutils literal"><span class="pre">CalledProcessError</span></tt></a>. The <a class="reference internal" href="#subprocess.CalledProcessError" title="subprocess.CalledProcessError"><tt class="xref py py-exc docutils literal"><span class="pre">CalledProcessError</span></tt></a> object will have the return code in the <tt class="xref py py-attr docutils literal"><span class="pre">returncode</span></tt> attribute.</p> <p>The arguments shown above are merely the most common ones, described below in <a class="reference internal" href="#frequently-used-arguments"><em>Frequently Used Arguments</em></a> (hence the slightly odd notation in the abbreviated signature). The full function signature is the same as that of the <a class="reference internal" href="#subprocess.Popen" title="subprocess.Popen"><tt class="xref py py-class docutils literal"><span class="pre">Popen</span></tt></a> constructor - this functions passes all supplied arguments directly through to that interface.</p> <p>Examples:</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">subprocess</span><span class="o">.</span><span class="n">check_call</span><span class="p">([</span><span class="s">"ls"</span><span class="p">,</span> <span class="s">"-l"</span><span class="p">])</span> <span class="go">0</span> <span class="gp">>>> </span><span class="n">subprocess</span><span class="o">.</span><span class="n">check_call</span><span class="p">(</span><span class="s">"exit 1"</span><span class="p">,</span> <span class="n">shell</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span> <span class="gt">Traceback (most recent call last):</span> <span class="c">...</span> <span class="gr">subprocess.CalledProcessError</span>: <span class="n">Command 'exit 1' returned non-zero exit status 1</span> </pre></div> </div> <p class="versionadded"> <span class="versionmodified">New in version 2.5.</span></p> <div class="admonition warning"> <p class="first admonition-title">Warning</p> <p class="last">Invoking the system shell with <tt class="docutils literal"><span class="pre">shell=True</span></tt> can be a security hazard if combined with untrusted input. See the warning under <a class="reference internal" href="#frequently-used-arguments"><em>Frequently Used Arguments</em></a> for details.</p> </div> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">Do not use <tt class="docutils literal"><span class="pre">stdout=PIPE</span></tt> or <tt class="docutils literal"><span class="pre">stderr=PIPE</span></tt> with this function. As the pipes are not being read in the current process, the child process may block if it generates enough output to a pipe to fill up the OS pipe buffer.</p> </div> </dd></dl> <dl class="function"> <dt id="subprocess.check_output"> <tt class="descclassname">subprocess.</tt><tt class="descname">check_output</tt><big>(</big><em>args</em>, <em>*</em>, <em>stdin=None</em>, <em>stderr=None</em>, <em>shell=False</em>, <em>universal_newlines=False</em><big>)</big><a class="headerlink" href="#subprocess.check_output" title="Permalink to this definition">¶</a></dt> <dd><p>Run command with arguments and return its output as a byte string.</p> <p>If the return code was non-zero it raises a <a class="reference internal" href="#subprocess.CalledProcessError" title="subprocess.CalledProcessError"><tt class="xref py py-exc docutils literal"><span class="pre">CalledProcessError</span></tt></a>. The <a class="reference internal" href="#subprocess.CalledProcessError" title="subprocess.CalledProcessError"><tt class="xref py py-exc docutils literal"><span class="pre">CalledProcessError</span></tt></a> object will have the return code in the <tt class="xref py py-attr docutils literal"><span class="pre">returncode</span></tt> attribute and any output in the <tt class="xref py py-attr docutils literal"><span class="pre">output</span></tt> attribute.</p> <p>The arguments shown above are merely the most common ones, described below in <a class="reference internal" href="#frequently-used-arguments"><em>Frequently Used Arguments</em></a> (hence the slightly odd notation in the abbreviated signature). The full function signature is largely the same as that of the <a class="reference internal" href="#subprocess.Popen" title="subprocess.Popen"><tt class="xref py py-class docutils literal"><span class="pre">Popen</span></tt></a> constructor, except that <em>stdout</em> is not permitted as it is used internally. All other supplied arguments are passed directly through to the <a class="reference internal" href="#subprocess.Popen" title="subprocess.Popen"><tt class="xref py py-class docutils literal"><span class="pre">Popen</span></tt></a> constructor.</p> <p>Examples:</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">subprocess</span><span class="o">.</span><span class="n">check_output</span><span class="p">([</span><span class="s">"echo"</span><span class="p">,</span> <span class="s">"Hello World!"</span><span class="p">])</span> <span class="go">'Hello World!\n'</span> <span class="gp">>>> </span><span class="n">subprocess</span><span class="o">.</span><span class="n">check_output</span><span class="p">(</span><span class="s">"exit 1"</span><span class="p">,</span> <span class="n">shell</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span> <span class="gt">Traceback (most recent call last):</span> <span class="c">...</span> <span class="gr">subprocess.CalledProcessError</span>: <span class="n">Command 'exit 1' returned non-zero exit status 1</span> </pre></div> </div> <p>To also capture standard error in the result, use <tt class="docutils literal"><span class="pre">stderr=subprocess.STDOUT</span></tt>:</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="n">subprocess</span><span class="o">.</span><span class="n">check_output</span><span class="p">(</span> <span class="gp">... </span> <span class="s">"ls non_existent_file; exit 0"</span><span class="p">,</span> <span class="gp">... </span> <span class="n">stderr</span><span class="o">=</span><span class="n">subprocess</span><span class="o">.</span><span class="n">STDOUT</span><span class="p">,</span> <span class="gp">... </span> <span class="n">shell</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span> <span class="go">'ls: non_existent_file: No such file or directory\n'</span> </pre></div> </div> <p class="versionadded"> <span class="versionmodified">New in version 2.7.</span></p> <div class="admonition warning"> <p class="first admonition-title">Warning</p> <p class="last">Invoking the system shell with <tt class="docutils literal"><span class="pre">shell=True</span></tt> can be a security hazard if combined with untrusted input. See the warning under <a class="reference internal" href="#frequently-used-arguments"><em>Frequently Used Arguments</em></a> for details.</p> </div> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">Do not use <tt class="docutils literal"><span class="pre">stderr=PIPE</span></tt> with this function. As the pipe is not being read in the current process, the child process may block if it generates enough output to the pipe to fill up the OS pipe buffer.</p> </div> </dd></dl> <dl class="data"> <dt id="subprocess.PIPE"> <tt class="descclassname">subprocess.</tt><tt class="descname">PIPE</tt><a class="headerlink" href="#subprocess.PIPE" title="Permalink to this definition">¶</a></dt> <dd><p>Special value that can be used as the <em>stdin</em>, <em>stdout</em> or <em>stderr</em> argument to <a class="reference internal" href="#subprocess.Popen" title="subprocess.Popen"><tt class="xref py py-class docutils literal"><span class="pre">Popen</span></tt></a> and indicates that a pipe to the standard stream should be opened.</p> </dd></dl> <dl class="data"> <dt id="subprocess.STDOUT"> <tt class="descclassname">subprocess.</tt><tt class="descname">STDOUT</tt><a class="headerlink" href="#subprocess.STDOUT" title="Permalink to this definition">¶</a></dt> <dd><p>Special value that can be used as the <em>stderr</em> argument to <a class="reference internal" href="#subprocess.Popen" title="subprocess.Popen"><tt class="xref py py-class docutils literal"><span class="pre">Popen</span></tt></a> and indicates that standard error should go into the same handle as standard output.</p> </dd></dl> <dl class="exception"> <dt id="subprocess.CalledProcessError"> <em class="property">exception </em><tt class="descclassname">subprocess.</tt><tt class="descname">CalledProcessError</tt><a class="headerlink" href="#subprocess.CalledProcessError" title="Permalink to this definition">¶</a></dt> <dd><p>Exception raised when a process run by <a class="reference internal" href="#subprocess.check_call" title="subprocess.check_call"><tt class="xref py py-func docutils literal"><span class="pre">check_call()</span></tt></a> or <a class="reference internal" href="#subprocess.check_output" title="subprocess.check_output"><tt class="xref py py-func docutils literal"><span class="pre">check_output()</span></tt></a> returns a non-zero exit status.</p> <dl class="attribute"> <dt id="subprocess.CalledProcessError.returncode"> <tt class="descname">returncode</tt><a class="headerlink" href="#subprocess.CalledProcessError.returncode" title="Permalink to this definition">¶</a></dt> <dd><p>Exit status of the child process.</p> </dd></dl> <dl class="attribute"> <dt id="subprocess.CalledProcessError.cmd"> <tt class="descname">cmd</tt><a class="headerlink" href="#subprocess.CalledProcessError.cmd" title="Permalink to this definition">¶</a></dt> <dd><p>Command that was used to spawn the child process.</p> </dd></dl> <dl class="attribute"> <dt id="subprocess.CalledProcessError.output"> <tt class="descname">output</tt><a class="headerlink" href="#subprocess.CalledProcessError.output" title="Permalink to this definition">¶</a></dt> <dd><p>Output of the child process if this exception is raised by <a class="reference internal" href="#subprocess.check_output" title="subprocess.check_output"><tt class="xref py py-func docutils literal"><span class="pre">check_output()</span></tt></a>. Otherwise, <tt class="docutils literal"><span class="pre">None</span></tt>.</p> </dd></dl> </dd></dl> <div class="section" id="frequently-used-arguments"> <span id="id1"></span><h3>17.1.1.1. Frequently Used Arguments<a class="headerlink" href="#frequently-used-arguments" title="Permalink to this headline">¶</a></h3> <p>To support a wide variety of use cases, the <a class="reference internal" href="#subprocess.Popen" title="subprocess.Popen"><tt class="xref py py-class docutils literal"><span class="pre">Popen</span></tt></a> constructor (and the convenience functions) accept a large number of optional arguments. For most typical use cases, many of these arguments can be safely left at their default values. The arguments that are most commonly needed are:</p> <blockquote> <div><p><em>args</em> is required for all calls and should be a string, or a sequence of program arguments. Providing a sequence of arguments is generally preferred, as it allows the module to take care of any required escaping and quoting of arguments (e.g. to permit spaces in file names). If passing a single string, either <em>shell</em> must be <a class="reference internal" href="constants.html#True" title="True"><tt class="xref py py-const docutils literal"><span class="pre">True</span></tt></a> (see below) or else the string must simply name the program to be executed without specifying any arguments.</p> <p><em>stdin</em>, <em>stdout</em> and <em>stderr</em> specify the executed program’s standard input, standard output and standard error file handles, respectively. Valid values are <a class="reference internal" href="#subprocess.PIPE" title="subprocess.PIPE"><tt class="xref py py-data docutils literal"><span class="pre">PIPE</span></tt></a>, an existing file descriptor (a positive integer), an existing file object, and <tt class="docutils literal"><span class="pre">None</span></tt>. <a class="reference internal" href="#subprocess.PIPE" title="subprocess.PIPE"><tt class="xref py py-data docutils literal"><span class="pre">PIPE</span></tt></a> indicates that a new pipe to the child should be created. With the default settings of <tt class="docutils literal"><span class="pre">None</span></tt>, no redirection will occur; the child’s file handles will be inherited from the parent. Additionally, <em>stderr</em> can be <a class="reference internal" href="#subprocess.STDOUT" title="subprocess.STDOUT"><tt class="xref py py-data docutils literal"><span class="pre">STDOUT</span></tt></a>, which indicates that the stderr data from the child process should be captured into the same file handle as for stdout.</p> <p id="index-1">When <em>stdout</em> or <em>stderr</em> are pipes and <em>universal_newlines</em> is <tt class="docutils literal"><span class="pre">True</span></tt> then all line endings will be converted to <tt class="docutils literal"><span class="pre">'\n'</span></tt> as described for the <a class="reference internal" href="../glossary.html#term-universal-newlines"><em class="xref std std-term">universal newlines</em></a> <tt class="docutils literal"><span class="pre">'U'</span></tt> mode argument to <a class="reference internal" href="functions.html#open" title="open"><tt class="xref py py-func docutils literal"><span class="pre">open()</span></tt></a>.</p> <p>If <em>shell</em> is <tt class="docutils literal"><span class="pre">True</span></tt>, the specified command will be executed through the shell. This can be useful if you are using Python primarily for the enhanced control flow it offers over most system shells and still want convenient access to other shell features such as shell pipes, filename wildcards, environment variable expansion, and expansion of <tt class="docutils literal"><span class="pre">~</span></tt> to a user’s home directory. However, note that Python itself offers implementations of many shell-like features (in particular, <a class="reference internal" href="glob.html#module-glob" title="glob: Unix shell style pathname pattern expansion."><tt class="xref py py-mod docutils literal"><span class="pre">glob</span></tt></a>, <a class="reference internal" href="fnmatch.html#module-fnmatch" title="fnmatch: Unix shell style filename pattern matching."><tt class="xref py py-mod docutils literal"><span class="pre">fnmatch</span></tt></a>, <a class="reference internal" href="os.html#os.walk" title="os.walk"><tt class="xref py py-func docutils literal"><span class="pre">os.walk()</span></tt></a>, <a class="reference internal" href="os.path.html#os.path.expandvars" title="os.path.expandvars"><tt class="xref py py-func docutils literal"><span class="pre">os.path.expandvars()</span></tt></a>, <a class="reference internal" href="os.path.html#os.path.expanduser" title="os.path.expanduser"><tt class="xref py py-func docutils literal"><span class="pre">os.path.expanduser()</span></tt></a>, and <a class="reference internal" href="shutil.html#module-shutil" title="shutil: High-level file operations, including copying."><tt class="xref py py-mod docutils literal"><span class="pre">shutil</span></tt></a>).</p> <div class="admonition warning"> <p class="first admonition-title">Warning</p> <p>Executing shell commands that incorporate unsanitized input from an untrusted source makes a program vulnerable to <a class="reference external" href="http://en.wikipedia.org/wiki/Shell_injection#Shell_injection">shell injection</a>, a serious security flaw which can result in arbitrary command execution. For this reason, the use of <tt class="docutils literal"><span class="pre">shell=True</span></tt> is <strong>strongly discouraged</strong> in cases where the command string is constructed from external input:</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">from</span> <span class="nn">subprocess</span> <span class="kn">import</span> <span class="n">call</span> <span class="gp">>>> </span><span class="n">filename</span> <span class="o">=</span> <span class="nb">input</span><span class="p">(</span><span class="s">"What file would you like to display?</span><span class="se">\n</span><span class="s">"</span><span class="p">)</span> <span class="go">What file would you like to display?</span> <span class="go">non_existent; rm -rf / #</span> <span class="gp">>>> </span><span class="n">call</span><span class="p">(</span><span class="s">"cat "</span> <span class="o">+</span> <span class="n">filename</span><span class="p">,</span> <span class="n">shell</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span> <span class="c"># Uh-oh. This will end badly...</span> </pre></div> </div> <p><tt class="docutils literal"><span class="pre">shell=False</span></tt> disables all shell based features, but does not suffer from this vulnerability; see the Note in the <a class="reference internal" href="#subprocess.Popen" title="subprocess.Popen"><tt class="xref py py-class docutils literal"><span class="pre">Popen</span></tt></a> constructor documentation for helpful hints in getting <tt class="docutils literal"><span class="pre">shell=False</span></tt> to work.</p> <p class="last">When using <tt class="docutils literal"><span class="pre">shell=True</span></tt>, <a class="reference internal" href="pipes.html#pipes.quote" title="pipes.quote"><tt class="xref py py-func docutils literal"><span class="pre">pipes.quote()</span></tt></a> can be used to properly escape whitespace and shell metacharacters in strings that are going to be used to construct shell commands.</p> </div> </div></blockquote> <p>These options, along with all of the other options, are described in more detail in the <a class="reference internal" href="#subprocess.Popen" title="subprocess.Popen"><tt class="xref py py-class docutils literal"><span class="pre">Popen</span></tt></a> constructor documentation.</p> </div> <div class="section" id="popen-constructor"> <h3>17.1.1.2. Popen Constructor<a class="headerlink" href="#popen-constructor" title="Permalink to this headline">¶</a></h3> <p>The underlying process creation and management in this module is handled by the <a class="reference internal" href="#subprocess.Popen" title="subprocess.Popen"><tt class="xref py py-class docutils literal"><span class="pre">Popen</span></tt></a> class. It offers a lot of flexibility so that developers are able to handle the less common cases not covered by the convenience functions.</p> <dl class="class"> <dt id="subprocess.Popen"> <em class="property">class </em><tt class="descclassname">subprocess.</tt><tt class="descname">Popen</tt><big>(</big><em>args</em>, <em>bufsize=0</em>, <em>executable=None</em>, <em>stdin=None</em>, <em>stdout=None</em>, <em>stderr=None</em>, <em>preexec_fn=None</em>, <em>close_fds=False</em>, <em>shell=False</em>, <em>cwd=None</em>, <em>env=None</em>, <em>universal_newlines=False</em>, <em>startupinfo=None</em>, <em>creationflags=0</em><big>)</big><a class="headerlink" href="#subprocess.Popen" title="Permalink to this definition">¶</a></dt> <dd><p>Execute a child program in a new process. On Unix, the class uses <a class="reference internal" href="os.html#os.execvp" title="os.execvp"><tt class="xref py py-meth docutils literal"><span class="pre">os.execvp()</span></tt></a>-like behavior to execute the child program. On Windows, the class uses the Windows <tt class="docutils literal"><span class="pre">CreateProcess()</span></tt> function. The arguments to <a class="reference internal" href="#subprocess.Popen" title="subprocess.Popen"><tt class="xref py py-class docutils literal"><span class="pre">Popen</span></tt></a> are as follows.</p> <p><em>args</em> should be a sequence of program arguments or else a single string. By default, the program to execute is the first item in <em>args</em> if <em>args</em> is a sequence. If <em>args</em> is a string, the interpretation is platform-dependent and described below. See the <em>shell</em> and <em>executable</em> arguments for additional differences from the default behavior. Unless otherwise stated, it is recommended to pass <em>args</em> as a sequence.</p> <p>On Unix, if <em>args</em> is a string, the string is interpreted as the name or path of the program to execute. However, this can only be done if not passing arguments to the program.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p><a class="reference internal" href="shlex.html#shlex.split" title="shlex.split"><tt class="xref py py-meth docutils literal"><span class="pre">shlex.split()</span></tt></a> can be useful when determining the correct tokenization for <em>args</em>, especially in complex cases:</p> <div class="highlight-python"><div class="highlight"><pre><span class="gp">>>> </span><span class="kn">import</span> <span class="nn">shlex</span><span class="o">,</span> <span class="nn">subprocess</span> <span class="gp">>>> </span><span class="n">command_line</span> <span class="o">=</span> <span class="nb">raw_input</span><span class="p">()</span> <span class="go">/bin/vikings -input eggs.txt -output "spam spam.txt" -cmd "echo '$MONEY'"</span> <span class="gp">>>> </span><span class="n">args</span> <span class="o">=</span> <span class="n">shlex</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">command_line</span><span class="p">)</span> <span class="gp">>>> </span><span class="k">print</span> <span class="n">args</span> <span class="go">['/bin/vikings', '-input', 'eggs.txt', '-output', 'spam spam.txt', '-cmd', "echo '$MONEY'"]</span> <span class="gp">>>> </span><span class="n">p</span> <span class="o">=</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">Popen</span><span class="p">(</span><span class="n">args</span><span class="p">)</span> <span class="c"># Success!</span> </pre></div> </div> <p class="last">Note in particular that options (such as <em>-input</em>) and arguments (such as <em>eggs.txt</em>) that are separated by whitespace in the shell go in separate list elements, while arguments that need quoting or backslash escaping when used in the shell (such as filenames containing spaces or the <em>echo</em> command shown above) are single list elements.</p> </div> <p>On Windows, if <em>args</em> is a sequence, it will be converted to a string in a manner described in <a class="reference internal" href="#converting-argument-sequence"><em>Converting an argument sequence to a string on Windows</em></a>. This is because the underlying <tt class="docutils literal"><span class="pre">CreateProcess()</span></tt> operates on strings.</p> <p>The <em>shell</em> argument (which defaults to <em>False</em>) specifies whether to use the shell as the program to execute. If <em>shell</em> is <em>True</em>, it is recommended to pass <em>args</em> as a string rather than as a sequence.</p> <p>On Unix with <tt class="docutils literal"><span class="pre">shell=True</span></tt>, the shell defaults to <tt class="file docutils literal"><span class="pre">/bin/sh</span></tt>. If <em>args</em> is a string, the string specifies the command to execute through the shell. This means that the string must be formatted exactly as it would be when typed at the shell prompt. This includes, for example, quoting or backslash escaping filenames with spaces in them. If <em>args</em> is a sequence, the first item specifies the command string, and any additional items will be treated as additional arguments to the shell itself. That is to say, <a class="reference internal" href="#subprocess.Popen" title="subprocess.Popen"><tt class="xref py py-class docutils literal"><span class="pre">Popen</span></tt></a> does the equivalent of:</p> <div class="highlight-python"><div class="highlight"><pre><span class="n">Popen</span><span class="p">([</span><span class="s">'/bin/sh'</span><span class="p">,</span> <span class="s">'-c'</span><span class="p">,</span> <span class="n">args</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="n">args</span><span class="p">[</span><span class="mi">1</span><span class="p">],</span> <span class="o">...</span><span class="p">])</span> </pre></div> </div> <p>On Windows with <tt class="docutils literal"><span class="pre">shell=True</span></tt>, the <span class="target" id="index-2"></span><tt class="xref std std-envvar docutils literal"><span class="pre">COMSPEC</span></tt> environment variable specifies the default shell. The only time you need to specify <tt class="docutils literal"><span class="pre">shell=True</span></tt> on Windows is when the command you wish to execute is built into the shell (e.g. <strong class="command">dir</strong> or <strong class="command">copy</strong>). You do not need <tt class="docutils literal"><span class="pre">shell=True</span></tt> to run a batch file or console-based executable.</p> <div class="admonition warning"> <p class="first admonition-title">Warning</p> <p class="last">Passing <tt class="docutils literal"><span class="pre">shell=True</span></tt> can be a security hazard if combined with untrusted input. See the warning under <a class="reference internal" href="#frequently-used-arguments"><em>Frequently Used Arguments</em></a> for details.</p> </div> <p><em>bufsize</em>, if given, has the same meaning as the corresponding argument to the built-in open() function: <tt class="xref py py-const docutils literal"><span class="pre">0</span></tt> means unbuffered, <tt class="xref py py-const docutils literal"><span class="pre">1</span></tt> means line buffered, any other positive value means use a buffer of (approximately) that size. A negative <em>bufsize</em> means to use the system default, which usually means fully buffered. The default value for <em>bufsize</em> is <tt class="xref py py-const docutils literal"><span class="pre">0</span></tt> (unbuffered).</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">If you experience performance issues, it is recommended that you try to enable buffering by setting <em>bufsize</em> to either -1 or a large enough positive value (such as 4096).</p> </div> <p>The <em>executable</em> argument specifies a replacement program to execute. It is very seldom needed. When <tt class="docutils literal"><span class="pre">shell=False</span></tt>, <em>executable</em> replaces the program to execute specified by <em>args</em>. However, the original <em>args</em> is still passed to the program. Most programs treat the program specified by <em>args</em> as the command name, which can then be different from the program actually executed. On Unix, the <em>args</em> name becomes the display name for the executable in utilities such as <strong class="program">ps</strong>. If <tt class="docutils literal"><span class="pre">shell=True</span></tt>, on Unix the <em>executable</em> argument specifies a replacement shell for the default <tt class="file docutils literal"><span class="pre">/bin/sh</span></tt>.</p> <p><em>stdin</em>, <em>stdout</em> and <em>stderr</em> specify the executed program’s standard input, standard output and standard error file handles, respectively. Valid values are <a class="reference internal" href="#subprocess.PIPE" title="subprocess.PIPE"><tt class="xref py py-data docutils literal"><span class="pre">PIPE</span></tt></a>, an existing file descriptor (a positive integer), an existing file object, and <tt class="docutils literal"><span class="pre">None</span></tt>. <a class="reference internal" href="#subprocess.PIPE" title="subprocess.PIPE"><tt class="xref py py-data docutils literal"><span class="pre">PIPE</span></tt></a> indicates that a new pipe to the child should be created. With the default settings of <tt class="docutils literal"><span class="pre">None</span></tt>, no redirection will occur; the child’s file handles will be inherited from the parent. Additionally, <em>stderr</em> can be <a class="reference internal" href="#subprocess.STDOUT" title="subprocess.STDOUT"><tt class="xref py py-data docutils literal"><span class="pre">STDOUT</span></tt></a>, which indicates that the stderr data from the child process should be captured into the same file handle as for stdout.</p> <p>If <em>preexec_fn</em> is set to a callable object, this object will be called in the child process just before the child is executed. (Unix only)</p> <p>If <em>close_fds</em> is true, all file descriptors except <tt class="xref py py-const docutils literal"><span class="pre">0</span></tt>, <tt class="xref py py-const docutils literal"><span class="pre">1</span></tt> and <tt class="xref py py-const docutils literal"><span class="pre">2</span></tt> will be closed before the child process is executed. (Unix only). Or, on Windows, if <em>close_fds</em> is true then no handles will be inherited by the child process. Note that on Windows, you cannot set <em>close_fds</em> to true and also redirect the standard handles by setting <em>stdin</em>, <em>stdout</em> or <em>stderr</em>.</p> <p>If <em>cwd</em> is not <tt class="docutils literal"><span class="pre">None</span></tt>, the child’s current directory will be changed to <em>cwd</em> before it is executed. Note that this directory is not considered when searching the executable, so you can’t specify the program’s path relative to <em>cwd</em>.</p> <p>If <em>env</em> is not <tt class="docutils literal"><span class="pre">None</span></tt>, it must be a mapping that defines the environment variables for the new process; these are used instead of inheriting the current process’ environment, which is the default behavior.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">If specified, <em>env</em> must provide any variables required for the program to execute. On Windows, in order to run a <a class="reference external" href="http://en.wikipedia.org/wiki/Side-by-Side_Assembly">side-by-side assembly</a> the specified <em>env</em> <strong>must</strong> include a valid <span class="target" id="index-3"></span><tt class="xref std std-envvar docutils literal"><span class="pre">SystemRoot</span></tt>.</p> </div> <p>If <em>universal_newlines</em> is <tt class="docutils literal"><span class="pre">True</span></tt>, the file objects <em>stdout</em> and <em>stderr</em> are opened as text files in <a class="reference internal" href="../glossary.html#term-universal-newlines"><em class="xref std std-term">universal newlines</em></a> mode. Lines may be terminated by any of <tt class="docutils literal"><span class="pre">'\n'</span></tt>, the Unix end-of-line convention, <tt class="docutils literal"><span class="pre">'\r'</span></tt>, the old Macintosh convention or <tt class="docutils literal"><span class="pre">'\r\n'</span></tt>, the Windows convention. All of these external representations are seen as <tt class="docutils literal"><span class="pre">'\n'</span></tt> by the Python program.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">This feature is only available if Python is built with universal newline support (the default). Also, the newlines attribute of the file objects <a class="reference internal" href="#subprocess.Popen.stdout" title="subprocess.Popen.stdout"><tt class="xref py py-attr docutils literal"><span class="pre">stdout</span></tt></a>, <a class="reference internal" href="#subprocess.Popen.stdin" title="subprocess.Popen.stdin"><tt class="xref py py-attr docutils literal"><span class="pre">stdin</span></tt></a> and <a class="reference internal" href="#subprocess.Popen.stderr" title="subprocess.Popen.stderr"><tt class="xref py py-attr docutils literal"><span class="pre">stderr</span></tt></a> are not updated by the communicate() method.</p> </div> <p>If given, <em>startupinfo</em> will be a <a class="reference internal" href="#subprocess.STARTUPINFO" title="subprocess.STARTUPINFO"><tt class="xref py py-class docutils literal"><span class="pre">STARTUPINFO</span></tt></a> object, which is passed to the underlying <tt class="docutils literal"><span class="pre">CreateProcess</span></tt> function. <em>creationflags</em>, if given, can be <a class="reference internal" href="#subprocess.CREATE_NEW_CONSOLE" title="subprocess.CREATE_NEW_CONSOLE"><tt class="xref py py-data docutils literal"><span class="pre">CREATE_NEW_CONSOLE</span></tt></a> or <a class="reference internal" href="#subprocess.CREATE_NEW_PROCESS_GROUP" title="subprocess.CREATE_NEW_PROCESS_GROUP"><tt class="xref py py-data docutils literal"><span class="pre">CREATE_NEW_PROCESS_GROUP</span></tt></a>. (Windows only)</p> </dd></dl> </div> <div class="section" id="exceptions"> <h3>17.1.1.3. Exceptions<a class="headerlink" href="#exceptions" title="Permalink to this headline">¶</a></h3> <p>Exceptions raised in the child process, before the new program has started to execute, will be re-raised in the parent. Additionally, the exception object will have one extra attribute called <tt class="xref py py-attr docutils literal"><span class="pre">child_traceback</span></tt>, which is a string containing traceback information from the child’s point of view.</p> <p>The most common exception raised is <a class="reference internal" href="exceptions.html#exceptions.OSError" title="exceptions.OSError"><tt class="xref py py-exc docutils literal"><span class="pre">OSError</span></tt></a>. This occurs, for example, when trying to execute a non-existent file. Applications should prepare for <a class="reference internal" href="exceptions.html#exceptions.OSError" title="exceptions.OSError"><tt class="xref py py-exc docutils literal"><span class="pre">OSError</span></tt></a> exceptions.</p> <p>A <a class="reference internal" href="exceptions.html#exceptions.ValueError" title="exceptions.ValueError"><tt class="xref py py-exc docutils literal"><span class="pre">ValueError</span></tt></a> will be raised if <a class="reference internal" href="#subprocess.Popen" title="subprocess.Popen"><tt class="xref py py-class docutils literal"><span class="pre">Popen</span></tt></a> is called with invalid arguments.</p> <p><a class="reference internal" href="#subprocess.check_call" title="subprocess.check_call"><tt class="xref py py-func docutils literal"><span class="pre">check_call()</span></tt></a> and <a class="reference internal" href="#subprocess.check_output" title="subprocess.check_output"><tt class="xref py py-func docutils literal"><span class="pre">check_output()</span></tt></a> will raise <a class="reference internal" href="#subprocess.CalledProcessError" title="subprocess.CalledProcessError"><tt class="xref py py-exc docutils literal"><span class="pre">CalledProcessError</span></tt></a> if the called process returns a non-zero return code.</p> </div> <div class="section" id="security"> <h3>17.1.1.4. Security<a class="headerlink" href="#security" title="Permalink to this headline">¶</a></h3> <p>Unlike some other popen functions, this implementation will never call a system shell implicitly. This means that all characters, including shell metacharacters, can safely be passed to child processes. Obviously, if the shell is invoked explicitly, then it is the application’s responsibility to ensure that all whitespace and metacharacters are quoted appropriately.</p> </div> </div> <div class="section" id="popen-objects"> <h2>17.1.2. Popen Objects<a class="headerlink" href="#popen-objects" title="Permalink to this headline">¶</a></h2> <p>Instances of the <a class="reference internal" href="#subprocess.Popen" title="subprocess.Popen"><tt class="xref py py-class docutils literal"><span class="pre">Popen</span></tt></a> class have the following methods:</p> <dl class="method"> <dt id="subprocess.Popen.poll"> <tt class="descclassname">Popen.</tt><tt class="descname">poll</tt><big>(</big><big>)</big><a class="headerlink" href="#subprocess.Popen.poll" title="Permalink to this definition">¶</a></dt> <dd><p>Check if child process has terminated. Set and return <a class="reference internal" href="#subprocess.Popen.returncode" title="subprocess.Popen.returncode"><tt class="xref py py-attr docutils literal"><span class="pre">returncode</span></tt></a> attribute.</p> </dd></dl> <dl class="method"> <dt id="subprocess.Popen.wait"> <tt class="descclassname">Popen.</tt><tt class="descname">wait</tt><big>(</big><big>)</big><a class="headerlink" href="#subprocess.Popen.wait" title="Permalink to this definition">¶</a></dt> <dd><p>Wait for child process to terminate. Set and return <a class="reference internal" href="#subprocess.Popen.returncode" title="subprocess.Popen.returncode"><tt class="xref py py-attr docutils literal"><span class="pre">returncode</span></tt></a> attribute.</p> <div class="admonition warning"> <p class="first admonition-title">Warning</p> <p class="last">This will deadlock when using <tt class="docutils literal"><span class="pre">stdout=PIPE</span></tt> and/or <tt class="docutils literal"><span class="pre">stderr=PIPE</span></tt> and the child process generates enough output to a pipe such that it blocks waiting for the OS pipe buffer to accept more data. Use <a class="reference internal" href="#subprocess.Popen.communicate" title="subprocess.Popen.communicate"><tt class="xref py py-meth docutils literal"><span class="pre">communicate()</span></tt></a> to avoid that.</p> </div> </dd></dl> <dl class="method"> <dt id="subprocess.Popen.communicate"> <tt class="descclassname">Popen.</tt><tt class="descname">communicate</tt><big>(</big><em>input=None</em><big>)</big><a class="headerlink" href="#subprocess.Popen.communicate" title="Permalink to this definition">¶</a></dt> <dd><p>Interact with process: Send data to stdin. Read data from stdout and stderr, until end-of-file is reached. Wait for process to terminate. The optional <em>input</em> argument should be a string to be sent to the child process, or <tt class="docutils literal"><span class="pre">None</span></tt>, if no data should be sent to the child.</p> <p><a class="reference internal" href="#subprocess.Popen.communicate" title="subprocess.Popen.communicate"><tt class="xref py py-meth docutils literal"><span class="pre">communicate()</span></tt></a> returns a tuple <tt class="docutils literal"><span class="pre">(stdoutdata,</span> <span class="pre">stderrdata)</span></tt>.</p> <p>Note that if you want to send data to the process’s stdin, you need to create the Popen object with <tt class="docutils literal"><span class="pre">stdin=PIPE</span></tt>. Similarly, to get anything other than <tt class="docutils literal"><span class="pre">None</span></tt> in the result tuple, you need to give <tt class="docutils literal"><span class="pre">stdout=PIPE</span></tt> and/or <tt class="docutils literal"><span class="pre">stderr=PIPE</span></tt> too.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">The data read is buffered in memory, so do not use this method if the data size is large or unlimited.</p> </div> </dd></dl> <dl class="method"> <dt id="subprocess.Popen.send_signal"> <tt class="descclassname">Popen.</tt><tt class="descname">send_signal</tt><big>(</big><em>signal</em><big>)</big><a class="headerlink" href="#subprocess.Popen.send_signal" title="Permalink to this definition">¶</a></dt> <dd><p>Sends the signal <em>signal</em> to the child.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last">On Windows, SIGTERM is an alias for <a class="reference internal" href="#subprocess.Popen.terminate" title="subprocess.Popen.terminate"><tt class="xref py py-meth docutils literal"><span class="pre">terminate()</span></tt></a>. CTRL_C_EVENT and CTRL_BREAK_EVENT can be sent to processes started with a <em>creationflags</em> parameter which includes <cite>CREATE_NEW_PROCESS_GROUP</cite>.</p> </div> <p class="versionadded"> <span class="versionmodified">New in version 2.6.</span></p> </dd></dl> <dl class="method"> <dt id="subprocess.Popen.terminate"> <tt class="descclassname">Popen.</tt><tt class="descname">terminate</tt><big>(</big><big>)</big><a class="headerlink" href="#subprocess.Popen.terminate" title="Permalink to this definition">¶</a></dt> <dd><p>Stop the child. On Posix OSs the method sends SIGTERM to the child. On Windows the Win32 API function <tt class="xref c c-func docutils literal"><span class="pre">TerminateProcess()</span></tt> is called to stop the child.</p> <p class="versionadded"> <span class="versionmodified">New in version 2.6.</span></p> </dd></dl> <dl class="method"> <dt id="subprocess.Popen.kill"> <tt class="descclassname">Popen.</tt><tt class="descname">kill</tt><big>(</big><big>)</big><a class="headerlink" href="#subprocess.Popen.kill" title="Permalink to this definition">¶</a></dt> <dd><p>Kills the child. On Posix OSs the function sends SIGKILL to the child. On Windows <a class="reference internal" href="#subprocess.Popen.kill" title="subprocess.Popen.kill"><tt class="xref py py-meth docutils literal"><span class="pre">kill()</span></tt></a> is an alias for <a class="reference internal" href="#subprocess.Popen.terminate" title="subprocess.Popen.terminate"><tt class="xref py py-meth docutils literal"><span class="pre">terminate()</span></tt></a>.</p> <p class="versionadded"> <span class="versionmodified">New in version 2.6.</span></p> </dd></dl> <p>The following attributes are also available:</p> <div class="admonition warning"> <p class="first admonition-title">Warning</p> <p class="last">Use <a class="reference internal" href="#subprocess.Popen.communicate" title="subprocess.Popen.communicate"><tt class="xref py py-meth docutils literal"><span class="pre">communicate()</span></tt></a> rather than <a class="reference internal" href="#subprocess.Popen.stdin" title="subprocess.Popen.stdin"><tt class="xref py py-attr docutils literal"><span class="pre">.stdin.write</span></tt></a>, <a class="reference internal" href="#subprocess.Popen.stdout" title="subprocess.Popen.stdout"><tt class="xref py py-attr docutils literal"><span class="pre">.stdout.read</span></tt></a> or <a class="reference internal" href="#subprocess.Popen.stderr" title="subprocess.Popen.stderr"><tt class="xref py py-attr docutils literal"><span class="pre">.stderr.read</span></tt></a> to avoid deadlocks due to any of the other OS pipe buffers filling up and blocking the child process.</p> </div> <dl class="attribute"> <dt id="subprocess.Popen.stdin"> <tt class="descclassname">Popen.</tt><tt class="descname">stdin</tt><a class="headerlink" href="#subprocess.Popen.stdin" title="Permalink to this definition">¶</a></dt> <dd><p>If the <em>stdin</em> argument was <a class="reference internal" href="#subprocess.PIPE" title="subprocess.PIPE"><tt class="xref py py-data docutils literal"><span class="pre">PIPE</span></tt></a>, this attribute is a file object that provides input to the child process. Otherwise, it is <tt class="docutils literal"><span class="pre">None</span></tt>.</p> </dd></dl> <dl class="attribute"> <dt id="subprocess.Popen.stdout"> <tt class="descclassname">Popen.</tt><tt class="descname">stdout</tt><a class="headerlink" href="#subprocess.Popen.stdout" title="Permalink to this definition">¶</a></dt> <dd><p>If the <em>stdout</em> argument was <a class="reference internal" href="#subprocess.PIPE" title="subprocess.PIPE"><tt class="xref py py-data docutils literal"><span class="pre">PIPE</span></tt></a>, this attribute is a file object that provides output from the child process. Otherwise, it is <tt class="docutils literal"><span class="pre">None</span></tt>.</p> </dd></dl> <dl class="attribute"> <dt id="subprocess.Popen.stderr"> <tt class="descclassname">Popen.</tt><tt class="descname">stderr</tt><a class="headerlink" href="#subprocess.Popen.stderr" title="Permalink to this definition">¶</a></dt> <dd><p>If the <em>stderr</em> argument was <a class="reference internal" href="#subprocess.PIPE" title="subprocess.PIPE"><tt class="xref py py-data docutils literal"><span class="pre">PIPE</span></tt></a>, this attribute is a file object that provides error output from the child process. Otherwise, it is <tt class="docutils literal"><span class="pre">None</span></tt>.</p> </dd></dl> <dl class="attribute"> <dt id="subprocess.Popen.pid"> <tt class="descclassname">Popen.</tt><tt class="descname">pid</tt><a class="headerlink" href="#subprocess.Popen.pid" title="Permalink to this definition">¶</a></dt> <dd><p>The process ID of the child process.</p> <p>Note that if you set the <em>shell</em> argument to <tt class="docutils literal"><span class="pre">True</span></tt>, this is the process ID of the spawned shell.</p> </dd></dl> <dl class="attribute"> <dt id="subprocess.Popen.returncode"> <tt class="descclassname">Popen.</tt><tt class="descname">returncode</tt><a class="headerlink" href="#subprocess.Popen.returncode" title="Permalink to this definition">¶</a></dt> <dd><p>The child return code, set by <a class="reference internal" href="#subprocess.Popen.poll" title="subprocess.Popen.poll"><tt class="xref py py-meth docutils literal"><span class="pre">poll()</span></tt></a> and <a class="reference internal" href="#subprocess.Popen.wait" title="subprocess.Popen.wait"><tt class="xref py py-meth docutils literal"><span class="pre">wait()</span></tt></a> (and indirectly by <a class="reference internal" href="#subprocess.Popen.communicate" title="subprocess.Popen.communicate"><tt class="xref py py-meth docutils literal"><span class="pre">communicate()</span></tt></a>). A <tt class="docutils literal"><span class="pre">None</span></tt> value indicates that the process hasn’t terminated yet.</p> <p>A negative value <tt class="docutils literal"><span class="pre">-N</span></tt> indicates that the child was terminated by signal <tt class="docutils literal"><span class="pre">N</span></tt> (Unix only).</p> </dd></dl> </div> <div class="section" id="windows-popen-helpers"> <h2>17.1.3. Windows Popen Helpers<a class="headerlink" href="#windows-popen-helpers" title="Permalink to this headline">¶</a></h2> <p>The <a class="reference internal" href="#subprocess.STARTUPINFO" title="subprocess.STARTUPINFO"><tt class="xref py py-class docutils literal"><span class="pre">STARTUPINFO</span></tt></a> class and following constants are only available on Windows.</p> <dl class="class"> <dt id="subprocess.STARTUPINFO"> <em class="property">class </em><tt class="descclassname">subprocess.</tt><tt class="descname">STARTUPINFO</tt><a class="headerlink" href="#subprocess.STARTUPINFO" title="Permalink to this definition">¶</a></dt> <dd><p>Partial support of the Windows <a class="reference external" href="http://msdn.microsoft.com/en-us/library/ms686331(v=vs.85).aspx">STARTUPINFO</a> structure is used for <a class="reference internal" href="#subprocess.Popen" title="subprocess.Popen"><tt class="xref py py-class docutils literal"><span class="pre">Popen</span></tt></a> creation.</p> <dl class="attribute"> <dt id="subprocess.STARTUPINFO.dwFlags"> <tt class="descname">dwFlags</tt><a class="headerlink" href="#subprocess.STARTUPINFO.dwFlags" title="Permalink to this definition">¶</a></dt> <dd><p>A bit field that determines whether certain <a class="reference internal" href="#subprocess.STARTUPINFO" title="subprocess.STARTUPINFO"><tt class="xref py py-class docutils literal"><span class="pre">STARTUPINFO</span></tt></a> attributes are used when the process creates a window.</p> <div class="highlight-python"><div class="highlight"><pre><span class="n">si</span> <span class="o">=</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">STARTUPINFO</span><span class="p">()</span> <span class="n">si</span><span class="o">.</span><span class="n">dwFlags</span> <span class="o">=</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">STARTF_USESTDHANDLES</span> <span class="o">|</span> <span class="n">subprocess</span><span class="o">.</span><span class="n">STARTF_USESHOWWINDOW</span> </pre></div> </div> </dd></dl> <dl class="attribute"> <dt id="subprocess.STARTUPINFO.hStdInput"> <tt class="descname">hStdInput</tt><a class="headerlink" href="#subprocess.STARTUPINFO.hStdInput" title="Permalink to this definition">¶</a></dt> <dd><p>If <a class="reference internal" href="#subprocess.STARTUPINFO.dwFlags" title="subprocess.STARTUPINFO.dwFlags"><tt class="xref py py-attr docutils literal"><span class="pre">dwFlags</span></tt></a> specifies <a class="reference internal" href="#subprocess.STARTF_USESTDHANDLES" title="subprocess.STARTF_USESTDHANDLES"><tt class="xref py py-data docutils literal"><span class="pre">STARTF_USESTDHANDLES</span></tt></a>, this attribute is the standard input handle for the process. If <a class="reference internal" href="#subprocess.STARTF_USESTDHANDLES" title="subprocess.STARTF_USESTDHANDLES"><tt class="xref py py-data docutils literal"><span class="pre">STARTF_USESTDHANDLES</span></tt></a> is not specified, the default for standard input is the keyboard buffer.</p> </dd></dl> <dl class="attribute"> <dt id="subprocess.STARTUPINFO.hStdOutput"> <tt class="descname">hStdOutput</tt><a class="headerlink" href="#subprocess.STARTUPINFO.hStdOutput" title="Permalink to this definition">¶</a></dt> <dd><p>If <a class="reference internal" href="#subprocess.STARTUPINFO.dwFlags" title="subprocess.STARTUPINFO.dwFlags"><tt class="xref py py-attr docutils literal"><span class="pre">dwFlags</span></tt></a> specifies <a class="reference internal" href="#subprocess.STARTF_USESTDHANDLES" title="subprocess.STARTF_USESTDHANDLES"><tt class="xref py py-data docutils literal"><span class="pre">STARTF_USESTDHANDLES</span></tt></a>, this attribute is the standard output handle for the process. Otherwise, this attribute is ignored and the default for standard output is the console window’s buffer.</p> </dd></dl> <dl class="attribute"> <dt id="subprocess.STARTUPINFO.hStdError"> <tt class="descname">hStdError</tt><a class="headerlink" href="#subprocess.STARTUPINFO.hStdError" title="Permalink to this definition">¶</a></dt> <dd><p>If <a class="reference internal" href="#subprocess.STARTUPINFO.dwFlags" title="subprocess.STARTUPINFO.dwFlags"><tt class="xref py py-attr docutils literal"><span class="pre">dwFlags</span></tt></a> specifies <a class="reference internal" href="#subprocess.STARTF_USESTDHANDLES" title="subprocess.STARTF_USESTDHANDLES"><tt class="xref py py-data docutils literal"><span class="pre">STARTF_USESTDHANDLES</span></tt></a>, this attribute is the standard error handle for the process. Otherwise, this attribute is ignored and the default for standard error is the console window’s buffer.</p> </dd></dl> <dl class="attribute"> <dt id="subprocess.STARTUPINFO.wShowWindow"> <tt class="descname">wShowWindow</tt><a class="headerlink" href="#subprocess.STARTUPINFO.wShowWindow" title="Permalink to this definition">¶</a></dt> <dd><p>If <a class="reference internal" href="#subprocess.STARTUPINFO.dwFlags" title="subprocess.STARTUPINFO.dwFlags"><tt class="xref py py-attr docutils literal"><span class="pre">dwFlags</span></tt></a> specifies <a class="reference internal" href="#subprocess.STARTF_USESHOWWINDOW" title="subprocess.STARTF_USESHOWWINDOW"><tt class="xref py py-data docutils literal"><span class="pre">STARTF_USESHOWWINDOW</span></tt></a>, this attribute can be any of the values that can be specified in the <tt class="docutils literal"><span class="pre">nCmdShow</span></tt> parameter for the <a class="reference external" href="http://msdn.microsoft.com/en-us/library/ms633548(v=vs.85).aspx">ShowWindow</a> function, except for <tt class="docutils literal"><span class="pre">SW_SHOWDEFAULT</span></tt>. Otherwise, this attribute is ignored.</p> <p><a class="reference internal" href="#subprocess.SW_HIDE" title="subprocess.SW_HIDE"><tt class="xref py py-data docutils literal"><span class="pre">SW_HIDE</span></tt></a> is provided for this attribute. It is used when <a class="reference internal" href="#subprocess.Popen" title="subprocess.Popen"><tt class="xref py py-class docutils literal"><span class="pre">Popen</span></tt></a> is called with <tt class="docutils literal"><span class="pre">shell=True</span></tt>.</p> </dd></dl> </dd></dl> <div class="section" id="constants"> <h3>17.1.3.1. Constants<a class="headerlink" href="#constants" title="Permalink to this headline">¶</a></h3> <p>The <a class="reference internal" href="#module-subprocess" title="subprocess: Subprocess management."><tt class="xref py py-mod docutils literal"><span class="pre">subprocess</span></tt></a> module exposes the following constants.</p> <dl class="data"> <dt id="subprocess.STD_INPUT_HANDLE"> <tt class="descclassname">subprocess.</tt><tt class="descname">STD_INPUT_HANDLE</tt><a class="headerlink" href="#subprocess.STD_INPUT_HANDLE" title="Permalink to this definition">¶</a></dt> <dd><p>The standard input device. Initially, this is the console input buffer, <tt class="docutils literal"><span class="pre">CONIN$</span></tt>.</p> </dd></dl> <dl class="data"> <dt id="subprocess.STD_OUTPUT_HANDLE"> <tt class="descclassname">subprocess.</tt><tt class="descname">STD_OUTPUT_HANDLE</tt><a class="headerlink" href="#subprocess.STD_OUTPUT_HANDLE" title="Permalink to this definition">¶</a></dt> <dd><p>The standard output device. Initially, this is the active console screen buffer, <tt class="docutils literal"><span class="pre">CONOUT$</span></tt>.</p> </dd></dl> <dl class="data"> <dt id="subprocess.STD_ERROR_HANDLE"> <tt class="descclassname">subprocess.</tt><tt class="descname">STD_ERROR_HANDLE</tt><a class="headerlink" href="#subprocess.STD_ERROR_HANDLE" title="Permalink to this definition">¶</a></dt> <dd><p>The standard error device. Initially, this is the active console screen buffer, <tt class="docutils literal"><span class="pre">CONOUT$</span></tt>.</p> </dd></dl> <dl class="data"> <dt id="subprocess.SW_HIDE"> <tt class="descclassname">subprocess.</tt><tt class="descname">SW_HIDE</tt><a class="headerlink" href="#subprocess.SW_HIDE" title="Permalink to this definition">¶</a></dt> <dd><p>Hides the window. Another window will be activated.</p> </dd></dl> <dl class="data"> <dt id="subprocess.STARTF_USESTDHANDLES"> <tt class="descclassname">subprocess.</tt><tt class="descname">STARTF_USESTDHANDLES</tt><a class="headerlink" href="#subprocess.STARTF_USESTDHANDLES" title="Permalink to this definition">¶</a></dt> <dd><p>Specifies that the <a class="reference internal" href="#subprocess.STARTUPINFO.hStdInput" title="subprocess.STARTUPINFO.hStdInput"><tt class="xref py py-attr docutils literal"><span class="pre">STARTUPINFO.hStdInput</span></tt></a>, <a class="reference internal" href="#subprocess.STARTUPINFO.hStdOutput" title="subprocess.STARTUPINFO.hStdOutput"><tt class="xref py py-attr docutils literal"><span class="pre">STARTUPINFO.hStdOutput</span></tt></a>, and <a class="reference internal" href="#subprocess.STARTUPINFO.hStdError" title="subprocess.STARTUPINFO.hStdError"><tt class="xref py py-attr docutils literal"><span class="pre">STARTUPINFO.hStdError</span></tt></a> attributes contain additional information.</p> </dd></dl> <dl class="data"> <dt id="subprocess.STARTF_USESHOWWINDOW"> <tt class="descclassname">subprocess.</tt><tt class="descname">STARTF_USESHOWWINDOW</tt><a class="headerlink" href="#subprocess.STARTF_USESHOWWINDOW" title="Permalink to this definition">¶</a></dt> <dd><p>Specifies that the <a class="reference internal" href="#subprocess.STARTUPINFO.wShowWindow" title="subprocess.STARTUPINFO.wShowWindow"><tt class="xref py py-attr docutils literal"><span class="pre">STARTUPINFO.wShowWindow</span></tt></a> attribute contains additional information.</p> </dd></dl> <dl class="data"> <dt id="subprocess.CREATE_NEW_CONSOLE"> <tt class="descclassname">subprocess.</tt><tt class="descname">CREATE_NEW_CONSOLE</tt><a class="headerlink" href="#subprocess.CREATE_NEW_CONSOLE" title="Permalink to this definition">¶</a></dt> <dd><p>The new process has a new console, instead of inheriting its parent’s console (the default).</p> <p>This flag is always set when <a class="reference internal" href="#subprocess.Popen" title="subprocess.Popen"><tt class="xref py py-class docutils literal"><span class="pre">Popen</span></tt></a> is created with <tt class="docutils literal"><span class="pre">shell=True</span></tt>.</p> </dd></dl> <dl class="data"> <dt id="subprocess.CREATE_NEW_PROCESS_GROUP"> <tt class="descclassname">subprocess.</tt><tt class="descname">CREATE_NEW_PROCESS_GROUP</tt><a class="headerlink" href="#subprocess.CREATE_NEW_PROCESS_GROUP" title="Permalink to this definition">¶</a></dt> <dd><p>A <a class="reference internal" href="#subprocess.Popen" title="subprocess.Popen"><tt class="xref py py-class docutils literal"><span class="pre">Popen</span></tt></a> <tt class="docutils literal"><span class="pre">creationflags</span></tt> parameter to specify that a new process group will be created. This flag is necessary for using <a class="reference internal" href="os.html#os.kill" title="os.kill"><tt class="xref py py-func docutils literal"><span class="pre">os.kill()</span></tt></a> on the subprocess.</p> <p>This flag is ignored if <a class="reference internal" href="#subprocess.CREATE_NEW_CONSOLE" title="subprocess.CREATE_NEW_CONSOLE"><tt class="xref py py-data docutils literal"><span class="pre">CREATE_NEW_CONSOLE</span></tt></a> is specified.</p> </dd></dl> </div> </div> <div class="section" id="replacing-older-functions-with-the-subprocess-module"> <span id="subprocess-replacements"></span><h2>17.1.4. Replacing Older Functions with the <a class="reference internal" href="#module-subprocess" title="subprocess: Subprocess management."><tt class="xref py py-mod docutils literal"><span class="pre">subprocess</span></tt></a> Module<a class="headerlink" href="#replacing-older-functions-with-the-subprocess-module" title="Permalink to this headline">¶</a></h2> <p>In this section, “a becomes b” means that b can be used as a replacement for a.</p> <div class="admonition note"> <p class="first admonition-title">Note</p> <p>All “a” functions in this section fail (more or less) silently if the executed program cannot be found; the “b” replacements raise <a class="reference internal" href="exceptions.html#exceptions.OSError" title="exceptions.OSError"><tt class="xref py py-exc docutils literal"><span class="pre">OSError</span></tt></a> instead.</p> <p class="last">In addition, the replacements using <a class="reference internal" href="#subprocess.check_output" title="subprocess.check_output"><tt class="xref py py-func docutils literal"><span class="pre">check_output()</span></tt></a> will fail with a <a class="reference internal" href="#subprocess.CalledProcessError" title="subprocess.CalledProcessError"><tt class="xref py py-exc docutils literal"><span class="pre">CalledProcessError</span></tt></a> if the requested operation produces a non-zero return code. The output is still available as the <tt class="docutils literal"><span class="pre">output</span></tt> attribute of the raised exception.</p> </div> <p>In the following examples, we assume that the relevant functions have already been imported from the <a class="reference internal" href="#module-subprocess" title="subprocess: Subprocess management."><tt class="xref py py-mod docutils literal"><span class="pre">subprocess</span></tt></a> module.</p> <div class="section" id="replacing-bin-sh-shell-backquote"> <h3>17.1.4.1. Replacing /bin/sh shell backquote<a class="headerlink" href="#replacing-bin-sh-shell-backquote" title="Permalink to this headline">¶</a></h3> <div class="highlight-python"><pre>output=`mycmd myarg` # becomes output = check_output(["mycmd", "myarg"])</pre> </div> </div> <div class="section" id="replacing-shell-pipeline"> <h3>17.1.4.2. Replacing shell pipeline<a class="headerlink" href="#replacing-shell-pipeline" title="Permalink to this headline">¶</a></h3> <div class="highlight-python"><pre>output=`dmesg | grep hda` # becomes p1 = Popen(["dmesg"], stdout=PIPE) p2 = Popen(["grep", "hda"], stdin=p1.stdout, stdout=PIPE) p1.stdout.close() # Allow p1 to receive a SIGPIPE if p2 exits. output = p2.communicate()[0]</pre> </div> <p>The p1.stdout.close() call after starting the p2 is important in order for p1 to receive a SIGPIPE if p2 exits before p1.</p> <p>Alternatively, for trusted input, the shell’s own pipeline support may still be used directly:</p> <div class="highlight-python"><pre>output=`dmesg | grep hda` # becomes output=check_output("dmesg | grep hda", shell=True)</pre> </div> </div> <div class="section" id="replacing-os-system"> <h3>17.1.4.3. Replacing <a class="reference internal" href="os.html#os.system" title="os.system"><tt class="xref py py-func docutils literal"><span class="pre">os.system()</span></tt></a><a class="headerlink" href="#replacing-os-system" title="Permalink to this headline">¶</a></h3> <div class="highlight-python"><div class="highlight"><pre><span class="n">sts</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">system</span><span class="p">(</span><span class="s">"mycmd"</span> <span class="o">+</span> <span class="s">" myarg"</span><span class="p">)</span> <span class="c"># becomes</span> <span class="n">sts</span> <span class="o">=</span> <span class="n">call</span><span class="p">(</span><span class="s">"mycmd"</span> <span class="o">+</span> <span class="s">" myarg"</span><span class="p">,</span> <span class="n">shell</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span> </pre></div> </div> <p>Notes:</p> <ul class="simple"> <li>Calling the program through the shell is usually not required.</li> </ul> <p>A more realistic example would look like this:</p> <div class="highlight-python"><div class="highlight"><pre><span class="k">try</span><span class="p">:</span> <span class="n">retcode</span> <span class="o">=</span> <span class="n">call</span><span class="p">(</span><span class="s">"mycmd"</span> <span class="o">+</span> <span class="s">" myarg"</span><span class="p">,</span> <span class="n">shell</span><span class="o">=</span><span class="bp">True</span><span class="p">)</span> <span class="k">if</span> <span class="n">retcode</span> <span class="o"><</span> <span class="mi">0</span><span class="p">:</span> <span class="k">print</span> <span class="o">>></span><span class="n">sys</span><span class="o">.</span><span class="n">stderr</span><span class="p">,</span> <span class="s">"Child was terminated by signal"</span><span class="p">,</span> <span class="o">-</span><span class="n">retcode</span> <span class="k">else</span><span class="p">:</span> <span class="k">print</span> <span class="o">>></span><span class="n">sys</span><span class="o">.</span><span class="n">stderr</span><span class="p">,</span> <span class="s">"Child returned"</span><span class="p">,</span> <span class="n">retcode</span> <span class="k">except</span> <span class="ne">OSError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span> <span class="k">print</span> <span class="o">>></span><span class="n">sys</span><span class="o">.</span><span class="n">stderr</span><span class="p">,</span> <span class="s">"Execution failed:"</span><span class="p">,</span> <span class="n">e</span> </pre></div> </div> </div> <div class="section" id="replacing-the-os-spawn-family"> <h3>17.1.4.4. Replacing the <a class="reference internal" href="os.html#os.spawnl" title="os.spawnl"><tt class="xref py py-func docutils literal"><span class="pre">os.spawn</span></tt></a> family<a class="headerlink" href="#replacing-the-os-spawn-family" title="Permalink to this headline">¶</a></h3> <p>P_NOWAIT example:</p> <div class="highlight-python"><pre>pid = os.spawnlp(os.P_NOWAIT, "/bin/mycmd", "mycmd", "myarg") ==> pid = Popen(["/bin/mycmd", "myarg"]).pid</pre> </div> <p>P_WAIT example:</p> <div class="highlight-python"><pre>retcode = os.spawnlp(os.P_WAIT, "/bin/mycmd", "mycmd", "myarg") ==> retcode = call(["/bin/mycmd", "myarg"])</pre> </div> <p>Vector example:</p> <div class="highlight-python"><pre>os.spawnvp(os.P_NOWAIT, path, args) ==> Popen([path] + args[1:])</pre> </div> <p>Environment example:</p> <div class="highlight-python"><pre>os.spawnlpe(os.P_NOWAIT, "/bin/mycmd", "mycmd", "myarg", env) ==> Popen(["/bin/mycmd", "myarg"], env={"PATH": "/usr/bin"})</pre> </div> </div> <div class="section" id="replacing-os-popen-os-popen2-os-popen3"> <h3>17.1.4.5. Replacing <a class="reference internal" href="os.html#os.popen" title="os.popen"><tt class="xref py py-func docutils literal"><span class="pre">os.popen()</span></tt></a>, <a class="reference internal" href="os.html#os.popen2" title="os.popen2"><tt class="xref py py-func docutils literal"><span class="pre">os.popen2()</span></tt></a>, <a class="reference internal" href="os.html#os.popen3" title="os.popen3"><tt class="xref py py-func docutils literal"><span class="pre">os.popen3()</span></tt></a><a class="headerlink" href="#replacing-os-popen-os-popen2-os-popen3" title="Permalink to this headline">¶</a></h3> <div class="highlight-python"><pre>pipe = os.popen("cmd", 'r', bufsize) ==> pipe = Popen("cmd", shell=True, bufsize=bufsize, stdout=PIPE).stdout</pre> </div> <div class="highlight-python"><pre>pipe = os.popen("cmd", 'w', bufsize) ==> pipe = Popen("cmd", shell=True, bufsize=bufsize, stdin=PIPE).stdin</pre> </div> <div class="highlight-python"><pre>(child_stdin, child_stdout) = os.popen2("cmd", mode, bufsize) ==> p = Popen("cmd", shell=True, bufsize=bufsize, stdin=PIPE, stdout=PIPE, close_fds=True) (child_stdin, child_stdout) = (p.stdin, p.stdout)</pre> </div> <div class="highlight-python"><pre>(child_stdin, child_stdout, child_stderr) = os.popen3("cmd", mode, bufsize) ==> p = Popen("cmd", shell=True, bufsize=bufsize, stdin=PIPE, stdout=PIPE, stderr=PIPE, close_fds=True) (child_stdin, child_stdout, child_stderr) = (p.stdin, p.stdout, p.stderr)</pre> </div> <div class="highlight-python"><pre>(child_stdin, child_stdout_and_stderr) = os.popen4("cmd", mode, bufsize) ==> p = Popen("cmd", shell=True, bufsize=bufsize, stdin=PIPE, stdout=PIPE, stderr=STDOUT, close_fds=True) (child_stdin, child_stdout_and_stderr) = (p.stdin, p.stdout)</pre> </div> <p>On Unix, os.popen2, os.popen3 and os.popen4 also accept a sequence as the command to execute, in which case arguments will be passed directly to the program without shell intervention. This usage can be replaced as follows:</p> <div class="highlight-python"><pre>(child_stdin, child_stdout) = os.popen2(["/bin/ls", "-l"], mode, bufsize) ==> p = Popen(["/bin/ls", "-l"], bufsize=bufsize, stdin=PIPE, stdout=PIPE) (child_stdin, child_stdout) = (p.stdin, p.stdout)</pre> </div> <p>Return code handling translates as follows:</p> <div class="highlight-python"><pre>pipe = os.popen("cmd", 'w') ... rc = pipe.close() if rc is not None and rc >> 8: print "There were some errors" ==> process = Popen("cmd", 'w', shell=True, stdin=PIPE) ... process.stdin.close() if process.wait() != 0: print "There were some errors"</pre> </div> </div> <div class="section" id="replacing-functions-from-the-popen2-module"> <h3>17.1.4.6. Replacing functions from the <a class="reference internal" href="popen2.html#module-popen2" title="popen2: Subprocesses with accessible standard I/O streams. (deprecated)"><tt class="xref py py-mod docutils literal"><span class="pre">popen2</span></tt></a> module<a class="headerlink" href="#replacing-functions-from-the-popen2-module" title="Permalink to this headline">¶</a></h3> <div class="highlight-python"><pre>(child_stdout, child_stdin) = popen2.popen2("somestring", bufsize, mode) ==> p = Popen(["somestring"], shell=True, bufsize=bufsize, stdin=PIPE, stdout=PIPE, close_fds=True) (child_stdout, child_stdin) = (p.stdout, p.stdin)</pre> </div> <p>On Unix, popen2 also accepts a sequence as the command to execute, in which case arguments will be passed directly to the program without shell intervention. This usage can be replaced as follows:</p> <div class="highlight-python"><pre>(child_stdout, child_stdin) = popen2.popen2(["mycmd", "myarg"], bufsize, mode) ==> p = Popen(["mycmd", "myarg"], bufsize=bufsize, stdin=PIPE, stdout=PIPE, close_fds=True) (child_stdout, child_stdin) = (p.stdout, p.stdin)</pre> </div> <p><a class="reference internal" href="popen2.html#popen2.Popen3" title="popen2.Popen3"><tt class="xref py py-class docutils literal"><span class="pre">popen2.Popen3</span></tt></a> and <a class="reference internal" href="popen2.html#popen2.Popen4" title="popen2.Popen4"><tt class="xref py py-class docutils literal"><span class="pre">popen2.Popen4</span></tt></a> basically work as <a class="reference internal" href="#subprocess.Popen" title="subprocess.Popen"><tt class="xref py py-class docutils literal"><span class="pre">subprocess.Popen</span></tt></a>, except that:</p> <ul class="simple"> <li><a class="reference internal" href="#subprocess.Popen" title="subprocess.Popen"><tt class="xref py py-class docutils literal"><span class="pre">Popen</span></tt></a> raises an exception if the execution fails.</li> <li>the <em>capturestderr</em> argument is replaced with the <em>stderr</em> argument.</li> <li><tt class="docutils literal"><span class="pre">stdin=PIPE</span></tt> and <tt class="docutils literal"><span class="pre">stdout=PIPE</span></tt> must be specified.</li> <li>popen2 closes all file descriptors by default, but you have to specify <tt class="docutils literal"><span class="pre">close_fds=True</span></tt> with <a class="reference internal" href="#subprocess.Popen" title="subprocess.Popen"><tt class="xref py py-class docutils literal"><span class="pre">Popen</span></tt></a>.</li> </ul> </div> </div> <div class="section" id="notes"> <h2>17.1.5. Notes<a class="headerlink" href="#notes" title="Permalink to this headline">¶</a></h2> <div class="section" id="converting-an-argument-sequence-to-a-string-on-windows"> <span id="converting-argument-sequence"></span><h3>17.1.5.1. Converting an argument sequence to a string on Windows<a class="headerlink" href="#converting-an-argument-sequence-to-a-string-on-windows" title="Permalink to this headline">¶</a></h3> <p>On Windows, an <em>args</em> sequence is converted to a string that can be parsed using the following rules (which correspond to the rules used by the MS C runtime):</p> <ol class="arabic simple"> <li>Arguments are delimited by white space, which is either a space or a tab.</li> <li>A string surrounded by double quotation marks is interpreted as a single argument, regardless of white space contained within. A quoted string can be embedded in an argument.</li> <li>A double quotation mark preceded by a backslash is interpreted as a literal double quotation mark.</li> <li>Backslashes are interpreted literally, unless they immediately precede a double quotation mark.</li> <li>If backslashes immediately precede a double quotation mark, every pair of backslashes is interpreted as a literal backslash. If the number of backslashes is odd, the last backslash escapes the next double quotation mark as described in rule 3.</li> </ol> </div> </div> </div> </div> </div> </div> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="../contents.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">17.1. <tt class="docutils literal"><span class="pre">subprocess</span></tt> — Subprocess management</a><ul> <li><a class="reference internal" href="#using-the-subprocess-module">17.1.1. Using the <tt class="docutils literal"><span class="pre">subprocess</span></tt> Module</a><ul> <li><a class="reference internal" href="#frequently-used-arguments">17.1.1.1. Frequently Used Arguments</a></li> <li><a class="reference internal" href="#popen-constructor">17.1.1.2. Popen Constructor</a></li> <li><a class="reference internal" href="#exceptions">17.1.1.3. Exceptions</a></li> <li><a class="reference internal" href="#security">17.1.1.4. Security</a></li> </ul> </li> <li><a class="reference internal" href="#popen-objects">17.1.2. Popen Objects</a></li> <li><a class="reference internal" href="#windows-popen-helpers">17.1.3. Windows Popen Helpers</a><ul> <li><a class="reference internal" href="#constants">17.1.3.1. Constants</a></li> </ul> </li> <li><a class="reference internal" href="#replacing-older-functions-with-the-subprocess-module">17.1.4. Replacing Older Functions with the <tt class="docutils literal"><span class="pre">subprocess</span></tt> Module</a><ul> <li><a class="reference internal" href="#replacing-bin-sh-shell-backquote">17.1.4.1. Replacing /bin/sh shell backquote</a></li> <li><a class="reference internal" href="#replacing-shell-pipeline">17.1.4.2. Replacing shell pipeline</a></li> <li><a class="reference internal" href="#replacing-os-system">17.1.4.3. Replacing <tt class="docutils literal"><span class="pre">os.system()</span></tt></a></li> <li><a class="reference internal" href="#replacing-the-os-spawn-family">17.1.4.4. Replacing the <tt class="docutils literal"><span class="pre">os.spawn</span></tt> family</a></li> <li><a class="reference internal" href="#replacing-os-popen-os-popen2-os-popen3">17.1.4.5. Replacing <tt class="docutils literal"><span class="pre">os.popen()</span></tt>, <tt class="docutils literal"><span class="pre">os.popen2()</span></tt>, <tt class="docutils literal"><span class="pre">os.popen3()</span></tt></a></li> <li><a class="reference internal" href="#replacing-functions-from-the-popen2-module">17.1.4.6. Replacing functions from the <tt class="docutils literal"><span class="pre">popen2</span></tt> module</a></li> </ul> </li> <li><a class="reference internal" href="#notes">17.1.5. Notes</a><ul> <li><a class="reference internal" href="#converting-an-argument-sequence-to-a-string-on-windows">17.1.5.1. Converting an argument sequence to a string on Windows</a></li> </ul> </li> </ul> </li> </ul> <h4>Previous topic</h4> <p class="topless"><a href="ipc.html" title="previous chapter">17. Interprocess Communication and Networking</a></p> <h4>Next topic</h4> <p class="topless"><a href="socket.html" title="next chapter">17.2. <tt class="docutils literal"><span class="pre">socket</span></tt> — Low-level networking interface</a></p> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../bugs.html">Report a Bug</a></li> <li><a href="../_sources/library/subprocess.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <div class="clearer"></div> </div> <div class="related"> <h3>Navigation</h3> <ul> <li class="right" style="margin-right: 10px"> <a href="../genindex.html" title="General Index" >index</a></li> <li class="right" > <a href="../py-modindex.html" title="Python Module Index" >modules</a> |</li> <li class="right" > <a href="socket.html" title="17.2. socket — Low-level networking interface" >next</a> |</li> <li class="right" > <a href="ipc.html" title="17. Interprocess Communication and Networking" >previous</a> |</li> <li><img src="../_static/py.png" alt="" style="vertical-align: middle; margin-top: -1px"/></li> <li><a href="http://www.python.org/">Python</a> »</li> <li> <a href="../index.html">Python 2.7.5 documentation</a> » </li> <li><a href="index.html" >The Python Standard Library</a> »</li> <li><a href="ipc.html" >17. Interprocess Communication and Networking</a> »</li> </ul> </div> <div class="footer"> © <a href="../copyright.html">Copyright</a> 1990-2020, Python Software Foundation. <br /> The Python Software Foundation is a non-profit corporation. <a href="http://www.python.org/psf/donations/">Please donate.</a> <br /> Last updated on Oct 13, 2020. <a href="../bugs.html">Found a bug</a>? <br /> Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.3. </div> </body> </html>
Close