OpenWrt Forum Archive

Topic: Openwrt daemon not starting

The content of this topic has been archived on 23 Apr 2018. There are no obvious gaps in this topic, but there may still be some posts missing at the end.

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

Where is myserver.py located? You should use an absolute path to avoid problems.

mikma..It's in the same folder, /etc/init.d

Replace the line with this:

python /etc/init.d/myserver.py

The discussion might have continued from here.