I want to run the following commands just after bootup of Raspberry Pi running the raspbian wheezy:
sudo gcc -lpthread server.c -o wifiserver.osudo ./wifiserver.o
I created the following files and ran the following steps:
Created a script file named
auto_server_start.Contents are as follows:
#!bin/bash # /etc/init.d/auto_server_start ### BEGIN INIT INFO # Provides: auto_server_start # Required-Start: $all # Required-Stop: $remote_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: wifi server script # Description: Start wifi server at bootup ### END INIT INFO case "$1" in start) echo "running server program" sudo gcc -lpthread server.c -o wifiserver.o sudo ./wifiserver.o ;; stop) echo "stopping customized script" ;; *) echo "Usage: /etc/init.d/auto_server_start start|stop" exit 1 ;; esac exit 0Copied this file named
auto_server_startto/etc/init.d/directory and added execute permission usingchmod +x.Then
sudo update-rc.d auto_server_start defaults.
It gave some warning about mathkernel but I don't think that has anything to do with my script.
However on soft reboot I checked ps -e as well as top, nowhere does my wifiserver process show up.
Please suggest.
PS: I checked that the commands gcc and ./wifiserver.o were giving no warning and errors.
sudois pointless and potentially harmful here. An init script already has all the privileges it needs./usr/local/binand change the script to run it from there. Examine your system log for failure or warning messages. Post them here if you need help interpreting them.