重启光猫的代码大概长这样
#!/bin/sh
host_url="192.168.1.1"
user_name="user_name"
pass_word="password"
tmppath="/tmp/reboot_cat"
if [ ! -d "${tmppath}" ]; then
mkdir -p ${tmppath}
touch ${tmppath}/cookies.txt
fi
loginfo=`curl -s -L "http://${host_url}/cgi-bin/luci" -X POST -c ${tmppath}/cookies.txt -d "username=${user_name}&psd=${pass_word}"`
function reboot_cat()
{
mytoken=$(echo $loginfo |sed 's/{/\n/g' | grep token |awk '/realRestart/{print $2}'| sed $'s/\'//g')
curl -s -b ${tmppath}/cookies.txt http://192.168.1.1/cgi-bin/luci/admin/reboot -d 'token='$mytoken
echo -e "Restating..."
}
reboot_cat
exit
|