Python Script to ping a server
#1
any python devs out there who could knock up a small peice of code for me ?

on my xbmc home screen i've got startonlan/shutonlan icons to start and stop my server. using the <onclick> command i execute 'wol'.py or 'sol.py' from my scripts dir. ive added the executebuiltin() function of xbmc in these scripts to run a notification() informing the command has been accepted and the server is either starting or stopping.

i would like to further enhance this code if possible and would like some help.
what i would like to do is after the command has been executed ping an address (192.168.1.2 for instance) every 5 seconds or so, put this in a loop and when a response is recieved from the ping issue an xbmc notification() the server is online and exit the script.

the same for shutdown, ping the address until no reply is received and issue a xbmc notification() the server is stopped.

im sure others would benefit from this as well as myself, so if anyone can help out it would be great.

thanks. Smile
Reply
#2
i don't think ping functionality is part of python, so you will have to find some sort of module/code that takes care of this.
search google. but i'm not sure if this is newbie material.

here is one of theme i found after googling:
http://www.python.org/~jeremy/python.html



Reply

Logout Mark Read Team Forum Stats Members Help
Python Script to ping a server0