Advertisement
sxiii

Python World Ping for your webserver or terminal session

Jun 14th, 2014
312
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. #!/usr/bin/python
  2. # Super-small python script to ping web/internet or local hosts
  3. # This script will ping specified host 4 times and print output to your browser.
  4. # Save into your public document root of your webserver (under name "python-ping.py", for example)
  5. # Run in browser address bar like http://myserver.com/python-ping.py?p=yandex.ru
  6. # This way it will ping yandex.ru 4 times and print result to your browser.
  7. # Also you can run it without web browser right from your terminal session and get similar output:
  8. # python python-ping.py p=ya.ru
  9. # Written by Security XIII (at) gmail dot (you know what) on 15.06.2014
  10.  
  11. import cgi, commands
  12. form = cgi.FieldStorage()
  13. output = commands.getstatusoutput('ping -c 4 ' + form["p"].value)
  14. print "Content-Type: text/plain"
  15. print
  16. for line in output:
  17.     print(line)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement