<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: python subprocess over shell</title>
	<atom:link href="http://explanatorygap.net/2010/05/10/python-subprocess-over-shell/feed/" rel="self" type="application/rss+xml" />
	<link>http://explanatorygap.net/2010/05/10/python-subprocess-over-shell/</link>
	<description>many a slip 'twixt mind and lip...</description>
	<lastBuildDate>Mon, 10 May 2010 22:46:00 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
	<item>
		<title>By: Links for 2010-05-10</title>
		<link>http://explanatorygap.net/2010/05/10/python-subprocess-over-shell/comment-page-1/#comment-2283</link>
		<dc:creator>Links for 2010-05-10</dc:creator>
		<pubDate>Mon, 10 May 2010 22:46:00 +0000</pubDate>
		<guid isPermaLink="false">http://explanatorygap.net/?p=256#comment-2283</guid>
		<description><![CDATA[[...] 07:26: python subprocess instead of shell http://explanatorygap.net/2010/05/10/python-subprocess-over-shell/ [...]]]></description>
		<content:encoded><![CDATA[<p>[...] 07:26: python subprocess instead of shell <a href="http://explanatorygap.net/2010/05/10/python-subprocess-over-shell/" rel="nofollow">http://explanatorygap.net/2010/05/10/python-subprocess-over-shell/</a> [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: nigel kersten</title>
		<link>http://explanatorygap.net/2010/05/10/python-subprocess-over-shell/comment-page-1/#comment-2282</link>
		<dc:creator>nigel kersten</dc:creator>
		<pubDate>Mon, 10 May 2010 18:22:53 +0000</pubDate>
		<guid isPermaLink="false">http://explanatorygap.net/?p=256#comment-2282</guid>
		<description><![CDATA[Yep. A custom function I often use is one that returns a tuple of (stdout, stderr, returncode) so you can use it however you want.

I don&#039;t use it often, mainly because I still do python 2.4 work, but the convenience function check_call that appeared in 2.5 is quite useful too:

http://docs.python.org/library/subprocess.html#convenience-functions

&lt;blockquote&gt;
subprocess.check_call(*popenargs, **kwargs)
Run command with arguments. Wait for command to complete. If the exit code was zero then return, otherwise raise CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute.

The arguments are the same as for the Popen constructor. Example:

&gt;&gt;&gt; subprocess.check_call([&quot;ls&quot;, &quot;-l&quot;])
0
New in version 2.5.
&lt;/blockquote&gt;]]></description>
		<content:encoded><![CDATA[<p>Yep. A custom function I often use is one that returns a tuple of (stdout, stderr, returncode) so you can use it however you want.</p>
<p>I don&#8217;t use it often, mainly because I still do python 2.4 work, but the convenience function check_call that appeared in 2.5 is quite useful too:</p>
<p><a href="http://docs.python.org/library/subprocess.html#convenience-functions" rel="nofollow">http://docs.python.org/library/subprocess.html#convenience-functions</a></p>
<blockquote><p>
subprocess.check_call(*popenargs, **kwargs)<br />
Run command with arguments. Wait for command to complete. If the exit code was zero then return, otherwise raise CalledProcessError. The CalledProcessError object will have the return code in the returncode attribute.</p>
<p>The arguments are the same as for the Popen constructor. Example:</p>
<p>>>> subprocess.check_call(["ls", "-l"])<br />
0<br />
New in version 2.5.
</p></blockquote>
]]></content:encoded>
	</item>
	<item>
		<title>By: Preston</title>
		<link>http://explanatorygap.net/2010/05/10/python-subprocess-over-shell/comment-page-1/#comment-2281</link>
		<dc:creator>Preston</dc:creator>
		<pubDate>Mon, 10 May 2010 18:16:35 +0000</pubDate>
		<guid isPermaLink="false">http://explanatorygap.net/?p=256#comment-2281</guid>
		<description><![CDATA[for blind calls to commands (no communication needed), I actually have this snippet built into my TextMate boilerplate for Python sysadmin scripts:

from subprocess import Popen, call, STDOUT, PIPE

def sh(cmd):
    return Popen(cmd,shell=True,stdout=PIPE,stderr=PIPE).communicate()[0]

so calling a shell command is as easy as:

printer_xml = sh(&#039;system_profiler -xml SPPrintersDataType&#039;)]]></description>
		<content:encoded><![CDATA[<p>for blind calls to commands (no communication needed), I actually have this snippet built into my TextMate boilerplate for Python sysadmin scripts:</p>
<p>from subprocess import Popen, call, STDOUT, PIPE</p>
<p>def sh(cmd):<br />
    return Popen(cmd,shell=True,stdout=PIPE,stderr=PIPE).communicate()[0]</p>
<p>so calling a shell command is as easy as:</p>
<p>printer_xml = sh(&#8216;system_profiler -xml SPPrintersDataType&#8217;)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.315 seconds -->
