查看原文:http://dsouth.:9527/wordpress/archives/59.html 树莓派启用以后常常三两天就掉电重启一次,远程就再也连不上了,所以必须把nat123加到开机启动项里 一、写自动登录脚本expect sudo apt-get install expect 新建脚本expect sudo nano /mnt/expect.sh 写入以下内容 #!/bin/bash username="填你的用户名" mypwd="填你的密码" cmdnat123="sudo mono /mnt/nat123linux.sh" expect -c" spawn $cmdnat123 while { 1 } { expect { \"press any key to Continue\" { send \"\r\"; } \"enter your nat123 username\" { send \"$username\r\"; } \"enter your nat123 password\" { send \"$mypwd\r\"; } send \"$mypwd\r\"; } eof { send \"exit\r\"; } } sleep 5; } " echo "Exit ..." sleep 5 二、写检测脚本autostart sudo nano /mnt/autostart.sh 写入以下内容 #!/bin/bash while true do ps aux | grep nat123 | grep -v grep if [ $? -eq 0 ];then sleep 600 else sudo screen -S nat123 bash /mnt/expect.sh fi done 三、写入开机启动项 sudo nano /etc/rc.local 在文件中间加入以下命令 sudo bash /mnt/autostart.sh exit 0
参考文献: |
|