Ping an address?
#1
anyone know how to ping an address from within python? i would like to see if an address is alive. i want to conditionally run a script from within xbmc only if an address is available.
Reply
#2
i decided to take a different approach. i am trying to establish a socket on the server, and if sucessful, i will execute the script. but, its not going so well. i added some debug lines. here is the script and the log. anyone have experience with sockets?

import socket
s = socket.socket(socket.af_inet,socket.sock_stream)
try:
print('inside 1')
s.connect(('100.200.3.111',5678))
print('inside 2')
s.close()
print('inside 3')
xbmc.executescript('q:\\scripts\\autoplay.py')
print('inside 4')
except:
print('fail 5')



09-10-2005 21:57:44 info inside 1
09-10-2005 21:57:44 info
09-10-2005 21:57:44 info fail 5
09-10-2005 21:57:44 info
Reply
#3
looks like i had the second parameter wrong to the socket command.  this seems to work.

import socket
s = socket.socket(socket.af_inet,socket.sock_dgram)
try:
s.connect(('100.200.3.101',5678))
s.close()
xbmc.executescript('q:\\scripts\\autoplay.py')
except:
pass



Reply

Logout Mark Read Team Forum Stats Members Help
Ping an address?0