Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/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)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement