远程开机

#! /bin/bash
echo ''
echo -e "\033[1;31m正在远程开机 192.168.31.106...\033[0m"
wakeonlan 74:d4:35:99:3e:48 > /dev/null 2>&1
wakeonlan 74:d4:35:99:3e:48 > /dev/null 2>&1
time1=`date  +"%Y-%m-%d %H:%M:%S"`
start_seconds=$(date --date="$time1" +%s);
n=.
while true
do
	ping 192.168.31.106 -c 1 -W 1 > /dev/null 2>&1
	if [ $? -ne 0 ]; then
		echo -en "\r\033[1;31mPC暂未开启,请稍候$n\033[0m"
        n=$n.
	else
		time2=`date  +"%Y-%m-%d %H:%M:%S"`
		end_seconds=$(date --date="$time2" +%s);
		time_all=$((end_seconds-start_seconds))
		echo -e "\n\033[1;31mPC已开启,本次开机用时$time_all秒\033[0m\n"
		break
	fi
done

你可能感兴趣的:(远程开机)