I working on openwrt and I want to run a python script on bootup. For this, I have written my script and added it to /etc/rc.local
. After bootup, when i do ps xa
, I can find the script running but nothing prints on screen.
The steps I have followed are below -
bootpython.py - python script that needs to run on bootup
i=0
while(i<100):
print("HELLO \n")
i+=1
script.sh - Script added to rc.local
This script checks if there's wlan0 in ifconfig and only then, it runs the python code. After reboot, there's saved.txt file created and it has HELLO written in it. But /usr/bin/python3 /root/bootpython.py &
doesn't print anything on screen. If i run the script without booting the system (/root/script.sh
), it prints HELLO on screen. What am i missing here?
a=0
while [ $a -lt 100 ]
do
if ( ifconfig | grep wlan0 )
then
a=`expr $a + 1`
/usr/bin/python3 /root/bootpython.py > /root/saved.txt &
/usr/bin/python3 /root/bootpython.py &
break
fi
done
/etc/rc.local
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.
/root/script.sh &
exit 0