Another simple python module to test a ping return using Subprocess.
#!/usr/bin/python
"""
Description: This module tests a ping return
Author: Thiago de Freitas Oliveira Araujo
http://thiagodefreitas.com
thiago <at> thiagodefreitas.com
"""
import subprocess
class pingCommunication():
def __init__(self, ipToPing):
self.ipToPing = ipToPing
self.pingQuantity = "1"
def pingProcess(self):
pingTest = "ping -c "+ self.pingQuantity + ' ' + self.ipToPing
print pingTest
process = subprocess.Popen(pingTest, shell=True, stdout=subprocess.PIPE)
process.wait()
returnCodeTotal = process.returncode
print returnCodeTotal
if __name__ == "__main__":
comunicate = pingCommunication("192.168.36.19")
comunicate.pingProcess()












