Linux-Bulgaria.ORG
навигация

 

начало

пощенски списък

архив на групата

семинари ...

документи

как да ...

 

 

Предишно писмо Следващо писмо Предишно по тема Следващо по тема По Дата По тема (thread)

Re: lug-bg: connected?


  • Subject: Re: lug-bg: connected?
  • From: Vladimir Vitkov <vvitkov@xxxxxxxxx>
  • Date: Mon, 26 Sep 2005 12:10:09 +0300
  • Delivered-to: lug-bg-list@xxxxxxxxxxxxxxxxxx
  • Delivered-to: lug-bg@xxxxxxxxxxxxxxxxxx

Аз ползвам следното

#!/usr/bin/php
<?php
/*
Script for recconecting the Internet conecction. Check the state with ping,
then start killall and run ppp.
*/

$command='ping -q -c3 -I ppp0 194.145.63.12';// pinging dir.bg
$result=exec($command);
$result=trim($result);
$result=explode(' ',$result);
$result=$result[0];
//echo $result;

if (!($result=='rtt')){ // ping failed
       // start logging - write the log file
       $time = date(" H:i:s",time());
       $date = date("Y-m-d",time());
       $data="$date --- $time --- Net is down\n";
       $fp=fopen('/var/www/htdocs/net/net.txt','a+');
       @fwrite($fp,$data);
       @fclose($fp);
       // end logging

       $command='pppoe-stop';
       exec($command);              // stop adsl
       $command='ppp-off';
       exec($command);              // stop ppp profilakti4no
       $command='killall -9 pppd';
       exec($command);              // cleanup
       $command='killall -9 pppoe';
       exec($command);              // cleanup
       $command='pppoe-start';
       exec($command);              //start adsl
       $command='cp -f /etc/resolv1 /etc/resolv.conf 1>/dev/null 2>&1';
       exec($command);              // restore name resolution
                // start logging - write the log file
                $time = date(" H:i:s",time());
                $date = date("Y-m-d",time());
                $data="$date --- $time --- Net recconected\n";
                $fp=fopen('/var/www/htdocs/net/net.txt','a+');
                @fwrite($fp,$data);
                @fclose($fp);
                // end logging
//       }
}
return;
?>

рънвам го през крон на всеки 5 мин
Не е най-добрия но ми върши работа
--
С уважение,
Владимир Витков
ICQ: 7867203
e-mail: vvitkov@xxxxxxxxx
e-mail: vvitkov@xxxxxx
Ако не отговарям на писмата ви: http://6lyokavitza.org/mail



 

наши приятели

 

линукс за българи
http://linux-bg.org

FSA-BG
http://fsa-bg.org

OpenFest
http://openfest.org

FreeBSD BG
http://bg-freebsd.org

KDE-BG
http://kde.fsa-bg.org/

Gnome-BG
http://gnome.cult.bg/

проект OpenFMI
http://openfmi.net

NetField Forum
http://netField.ludost.net/forum/

 

 

Linux-Bulgaria.ORG

Mailing list messages are © Copyright their authors.