i want to run python script as a service. for that i followed instructions here.
for init script(myservice.sh), i copied as it is.
for myservice.py ,
import sys, struct
from socket import *
SIZE = 1024 # packet size
hostName = gethostbyname('0.0.0.0')
mySocket = socket( AF_INET, SOCK_DGRAM )
mySocket.bind((hostName,18736))
repeat = True
while repeat:
(data,addr) = mySocket.recvfrom(SIZE)
data = struct.unpack('d',data)
data=int(data[0])
file = open("output.txt", "w")
file.write(str(data))
file.close()
When i start service "sudo /etc/init.d/myservice.sh start". it successfully started.
when i send udp data, but nothing is happend to "output.txt". what is the problem here?