OpenWrt Forum Archive

Topic: Running my own app after boot completed

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

Hello,

I'm not a Linux expert, but I managed to write my own C program that I want to run automatically after booting is completed.

I tried using the init script similar to this...

#!/bin/sh /etc/rc.common
# Example script
# Copyright (C) 2007 OpenWrt.org

START=10
STOP=15

start() {       
        echo start
        testprogram
}                 

stop() {         
        echo stop
        # commands to kill application
}

My program printf a lot of information while running. However, after re-booting openWrt, the OS automatically starts the program running, but there is NO TEXT OUTPUT anymore, and the program also does NOT run correctly in general.

But if I manually start it from the command line like this "/etc/init.d/script start" everything works perfectly. I don't know why it works if I start it manually, but does not work properly when it starts automatically.

So It seems it needs a real shell to run from in order to work properly because of the TEXT output, and when its automatically run at boot up maybe there is no shell causing it to mess up?

Does anybody knows how I can start my app automatically after everything boots up without using init.d method, or how to get it to start from a shell automatically after boot up?

I tried so many things with the same result, I tried putting in "sh testprogram" thinking that would force it to start in a shell, but still doesn't work.

Any help would be appreciated.

Thanks
rough_neck

the text output is sent to stdout, which in the case of the autostart is undefined.
Try echo "start" > filename
where filename is a file.

The discussion might have continued from here.