[英]Shell Script on Boot up does not execute on Raspberry pi
I want to run the following commands just after bootup of Raspberry Pi running the raspbian wheezy:我想在运行 raspbian wheezy 的 Raspberry Pi 启动后运行以下命令:
sudo gcc -lpthread server.c -o wifiserver.o
sudo./wifiserver.o
I created the following files and ran the following steps:我创建了以下文件并运行了以下步骤:
Created a script file named auto_server_start
.创建了一个名为
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 0
Copied this file named auto_server_start
to /etc/init.d/
directory and added execute permission using chmod +x
.将此名为
auto_server_start
的文件复制到/etc/init.d/
目录并使用chmod +x
添加执行权限。
Then sudo update-rc.d auto_server_start defaults
.然后
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.它给出了一些关于 mathkernel 的警告,但我认为这与我的脚本无关。
However on soft reboot I checked ps -e
as well as top
, nowhere does my wifiserver
process show up.但是,在软重启时,我检查了
ps -e
和top
,我的wifiserver
进程没有出现。
Please suggest.请建议。
PS: I checked that the commands gcc
and ./wifiserver.o
were giving no warning and errors. PS:我检查了命令
gcc
和./wifiserver.o
没有给出警告和错误。
Created a script file named auto_server_start.创建了一个名为 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"
/usr/local/bin/wifiserver.o
;;
stop)
echo "stopping customized script"
;;
*)
echo "Usage: /etc/init.d/auto_server_start start|stop"
exit 1
;;
esac
exit 0
Copied this file named auto_server_start to /etc/init.d/ directory and added execute permission using chmod +x.将此名为 auto_server_start 的文件复制到 /etc/init.d/ 目录并使用 chmod +x 添加执行权限。
Then sudo update-rc.d auto_server_start defaults.然后 sudo update-rc.d auto_server_start 默认值。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.