Note that there are some explanatory texts on larger screens.

plurals
  1. POFailed ping request in Python script
    primarykey
    data
    text
    <p>I have a python script that want to ping a few (quite a few!) hosts. I have set this up to read the contents of a hosts.txt file as the hosts to ping in the script. The odd thing is that I am recieving the following error, for the first few addresses (no matter what they are):</p> <pre><code>Ping request could not find host 66.211.181.182. Please check the name and try again. </code></pre> <p>I have included the address shown above at twice (within the file) and it attempts a ping. Any thoughts on what I am doing wrong - I am a python newbie, so be gentle.</p> <hr> <p>Here is my script:</p> <pre class="lang-py prettyprint-override"><code>import subprocess hosts_file = open("hosts.txt","r") lines = hosts_file.readlines() for line in lines: ping = subprocess.Popen( ["ping", "-n", "1",line], stdout = subprocess.PIPE, stderr = subprocess.PIPE ) out, error = ping.communicate() print out print error hosts_file.close() </code></pre> <p>Here is my hosts.txt file:</p> <pre><code>66.211.181.182 178.236.5.39 173.194.67.94 66.211.181.182 </code></pre> <p>And here are the results from the above test:</p> <pre><code>Ping request could not find host 66.211.181.182 . Please check the name and try again. Ping request could not find host 178.236.5.39 . Please check the name and try again. Ping request could not find host 173.194.67.94 . Please check the name and try again. Pinging 66.211.181.182 with 32 bytes of data: Request timed out. Ping statistics for 66.211.181.182: Packets: Sent = 1, Received = 0, Lost = 1 (100% loss) </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload