Issue with Python ping sweep script
<pre><code>import subprocess 

nrange = "192.168.229."

for i in range(0, 254):
        address = nrange + str(i)
        res = subprocess.call(['ping', '-c', '3', address])
        if res == 0:
            print "ping to", address, "OK"
        elif res == 2:
            print "no response from", address
        else:
            print "ping to", address, "failed!"
</code></pre>

<pre class="lang-none prettyprint-override"><code>root@kali:~/Desktop# ./pypsweep.py
^C./pysweep.py: line 3: nrange: command not found
./pysweep.py: line 5: syntax error unexpected toke `('
./pysweep.py: line 5: `for i in range (0, 254):'
root@kali:~/Desktop#
</code></pre>

<p>I am having an issue the above code. I am attempting to write a ping sweep script through Python to run in bash. I have tried several examples posted by other people around the interwebs but non seem to be functioning for me. This code is one that I wrote based off the simplest example I could find. I'm not sure if I am just simply overlooking an obvious error or what the issue could be. Any assistance with this issue would be greatly appreciated.</p>

<p>This is being ran on VMware Workstation Pro on Kali Linux distro if that matters at all.</p>