<div class="gmail_quote">Hi All,<div><br></div><div>I am using the following snippet to check the availability of an IP address. If that IP addr is found free than it can be used later on for further operations.</div><div>

<div>Python ver 3.2</div>
<div>Windows OS</div></div><div><br></div><div>{{{</div><div><div>pingret = subprocess.Popen(&#39;ping {0}&#39;.format(IPaddr), shell=True,universal_newlines=True, \</div><div>                    stdout=subprocess.PIPE, stderr=subprocess.STDOUT)</div>


<div>status = pingret.wait()</div><div>if status == 0:</div><div>    print(&quot;WARN  The IP given in the input is not free&quot;)</div><div>.....</div><div>.....</div><div>}}}</div><div><br></div><div>Normal ping operation on windows cmd prompt can give 3 outputs.</div>


<div>1) &quot;destination host unreachable</div><div>2) &quot;request timed out&quot;</div><div>3) &quot;Reply from <a href="http://192.168.1.1" target="_blank">192.168.1.1</a>: bytes=32 time=3ms TTL=64&quot;</div><div><br>

</div><div>Now, </div>
<div>I was expecting the &quot;status&quot; in above snippet to hold &#39;0&#39; only in case of no. 3)</div><div>But even when we have case 1), &#39;status&#39; is holding &#39;0&#39;. </div><div>i.e. The exit status of ping is 0, even when destination host is unreachable.!</div>


<div><br></div><div>How do I make my snippet to work as desired. i.e even if destination host is unreachable, &#39;status&#39; should hold &#39;1&#39;  and hold &#39;0&#39; only when it gets reply from that ip address.??</div>


<div><br></div><div><br></div><div>Thanks,</div><div><br></div>Nikunj<span class="HOEnZb"><font color="#888888"><br><br><div><br></div><div><div dir="ltr"><div dir="ltr">--</div><div dir="ltr"><b style><i><span style="font-size:18pt;font-family:&#39;Wingdings 3&#39;;color:rgb(192,0,0)">7</span></i></b><span style="font-size:10pt;color:rgb(31,73,125)">Switch off as you go </span><span style="font-size:18pt;color:rgb(23,54,93)">|</span><b style><span style="font-size:18pt;font-family:Webdings;color:rgb(118,146,60)">q</span></b><span style="font-size:10pt;color:rgb(31,73,125)">Recycle always</span><span style="font-size:18pt;color:rgb(23,54,93)"> | </span><span style="font-size:18pt;font-family:Webdings;color:rgb(0,176,80)">P </span><span style="font-size:10pt;color:rgb(31,73,125)">Save Paper - Save Trees</span><span style="font-size:18pt;color:rgb(23,54,93)"> |</span><span style="font-size:18pt;color:rgb(89,89,89)"> </span><span style="font-size:10pt;color:rgb(31,73,125)">Go Green </span></div>


</div></div><br>
</font></span></div>
</div><br>