sxiii icon

Python World Ping for your webserver or terminal session

sxiii | PRO | 06/14/14 08:48:42 PM UTC | 0 ⭐ | 688 👁️ | Never ⏰ | []
Python |

810 B

|

None

|

0 👍

/

0 👎

#!/usr/bin/python
# Super-small python script to ping web/internet or local hosts
# This script will ping specified host 4 times and print output to your browser.
# Save into your public document root of your webserver (under name "python-ping.py", for example)
# Run in browser address bar like http://myserver.com/python-ping.py?p=yandex.ru
# This way it will ping yandex.ru 4 times and print result to your browser.
# Also you can run it without web browser right from your terminal session and get similar output:
# python python-ping.py p=ya.ru
# Written by Security XIII (at) gmail dot (you know what) on 15.06.2014
 
import cgi, commands
form = cgi.FieldStorage()
output = commands.getstatusoutput('ping -c 4 ' + form["p"].value)
print "Content-Type: text/plain"
print
for line in output:
    print(line)

Comments