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
print "ping to", address, "failed!"
^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):'
Your code does not have a shebang line. As a consequence, when this command is run:
the shell attempts to interpret ./pypsweep.py as the default type: a shell script. That is why you see the errors that you see.
There are two solutions.
Call python explicitly:
root@kali:~/Desktop# python ./pypsweep.py
Add this line to the beginning of your script:
If you python is not in /usr/bin, adjust the path appropriately.