In my etc/init.d folder I have written a script
I have written start up daemon, which will download a file from server, it will also run a python code, which will enable the server for file transfer.
The daemon looks something like this:
#!/bin/sh /etc/rc.common
START=99
STOP=100
start()
{
echo start
curl -O 192.168.XX.XXX/somelocation ##THIS IS WORKING
python myserver.py### THIS IS NOT WORKING
}
My python code looks something like this:
myserver.py
import socket # Import socket module
port = 60000 # Reserve a port for your service.
s = socket.socket() # Create a socket object
host = socket.gethostname() # Get local machine name
s.bind((host, port)) # Bind to the port
s.listen(5) # Now wait for client connection.
print 'Server listening....'
while True:
conn, addr = s.accept() # Establish connection with client.
print 'Got connection from', addr
data = conn.recv(1024)
print('Server received', repr(data))
Thanks in advance