1
1
# Script Name : ping_subnet.py
2
2
# Author : Craig Richards
3
3
# Created : 12th January 2012
4
- # Last Modified :
4
+ # Last Modified :
5
5
# Version : 1.0
6
6
7
- # Modifications :
7
+ # Modifications :
8
8
9
9
# Description : After supplying the first 3 octets it will scan the final range for available addresses
10
10
11
11
import os # Load the Library Module
12
- import subprocess # Load the Library Module
12
+ import subprocess # Load the Library Module
13
13
import sys # Load the Library Module
14
14
15
15
filename = sys .argv [0 ] # Sets a variable for the script name
30
30
elif os .name in ("nt" , "dos" , "ce" ): # Check the os, if it's windows then
31
31
myping = "ping -n 2 " # This is the ping command
32
32
33
- f = open ('ping_' + subnet + '.log' , 'w' ) # Open a logfile
33
+ f = open ('ping_' + subnet + '.log' , 'w' ) # Open a logfile
34
34
for ip in range (2 ,255 ): # Set the ip variable for the range of numbers
35
- ret = subprocess .call (myping + str (subnet )+ "." + str (ip ) , shell = True ,stdout = f ,stderr = subprocess .STDOUT ) # Run the command pinging the servers
35
+ ret = subprocess .call (myping + str (subnet ) + "." + str (ip ) ,
36
+ shell = True , stdout = f , stderr = subprocess .STDOUT ) # Run the command pinging the servers
36
37
if ret == 0 : # Depending on the response
37
- f .write (subnet + "." + str (ip ) + " is alive" + "\n " ) # Write out that you can receive a reponse
38
+ f .write (subnet + "." + str (ip ) + " is alive" + "\n " ) # Write out that you can receive a reponse
38
39
else :
39
- f .write (subnet + "." + str (ip ) + " did not respond" + "\n " ) # Write out you can't reach the box
40
+ f .write (subnet + "." + str (ip ) + " did not respond" + "\n " ) # Write out you can't reach the box
0 commit comments