CTUにネットdeナビ用の穴を開けたけど、よう考えたら電源オフやったら反応せん。ではWakeOnLanで起こせばええということで、こんなスクリプトをおうちサーバに仕込む。
<html><head></head> <BODY> <?php $pass="nanchara"; $pw=$_POST['pass']; if($pw == $pass){ echo exec('"C:\Program Files\tools\wakeup\wakeup.exe" /b:192.168.*.255 00:00:00:00:00:00'); echo '<BR>'; }else{ echo "password error!\n"; } ?> <a href=".">return</a> </BODY> </HTML>
使用したのはリモートコンピュータの電源を入れる wakeup for Windows 98/Me/NT4.0/2000
RD-S601が起動しているか確認するためにおうちサーバからRD-S601にpingするスクリプト。
<html><head></head> <BODY> <?php $pass="nanchara"; $pw=$_POST['pass']; if($pw == $pass){ exec('ping rd-s601 >temp.txt'); $ret = file_get_contents('temp.txt'); $ret = str_replace("\n","<BR>",$ret); echo $ret; }else{ echo "password error!\n"; } ?> <a href=".">return</a> </BODY> </HTML>
最初のスクリプトのようなexecの結果を表示するようなやり方やpopenを使うやり方はうまくいかなかったので一時ファイルを書き出すことに。
index.htmlはこんな感じ。
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <HTML> <HEAD> <META http-equiv="Content-Type" content="text/html; charset=SHIFT_JIS"> <TITLE></TITLE> </HEAD> <BODY> <p> <form action="wake.php" method="post"> <input type="password" name="pass"> <input type="submit" name="submit" value="wake"> </form> </p> <p> <form action="ping.php" method="post"> <input type="password" name="pass"> <input type="submit" name="submit" value="ping"> </form> </p> </BODY> </HTML>
あとはメール予約の環境づくりが未。