Strict Standards: Non-static method utf_normalizer::nfkc() should not be called statically in /home/mati/domains/forum.programosy.pl/public_html/includes/utf/utf_tools.php on line 1663

Strict Standards: Non-static method utf_normalizer::nfkc() should not be called statically in /home/mati/domains/forum.programosy.pl/public_html/includes/utf/utf_tools.php on line 1663

Strict Standards: Non-static method utf_normalizer::nfkc() should not be called statically in /home/mati/domains/forum.programosy.pl/public_html/includes/utf/utf_tools.php on line 1663

Strict Standards: Non-static method utf_normalizer::nfkc() should not be called statically in /home/mati/domains/forum.programosy.pl/public_html/includes/utf/utf_tools.php on line 1663

Strict Standards: Non-static method utf_normalizer::nfkc() should not be called statically in /home/mati/domains/forum.programosy.pl/public_html/includes/utf/utf_tools.php on line 1663

Strict Standards: Non-static method utf_normalizer::nfkc() should not be called statically in /home/mati/domains/forum.programosy.pl/public_html/includes/utf/utf_tools.php on line 1663

Strict Standards: Non-static method utf_normalizer::nfkc() should not be called statically in /home/mati/domains/forum.programosy.pl/public_html/includes/utf/utf_tools.php on line 1663

Strict Standards: Non-static method utf_normalizer::nfkc() should not be called statically in /home/mati/domains/forum.programosy.pl/public_html/includes/utf/utf_tools.php on line 1663

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 483

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 112

Strict Standards: Non-static method utf_normalizer::nfkc() should not be called statically in /home/mati/domains/forum.programosy.pl/public_html/includes/utf/utf_tools.php on line 1663

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 112

Strict Standards: Non-static method utf_normalizer::nfkc() should not be called statically in /home/mati/domains/forum.programosy.pl/public_html/includes/utf/utf_tools.php on line 1663

Strict Standards: Non-static method utf_normalizer::nfkc() should not be called statically in /home/mati/domains/forum.programosy.pl/public_html/includes/utf/utf_tools.php on line 1663

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 112

Strict Standards: Non-static method utf_normalizer::nfkc() should not be called statically in /home/mati/domains/forum.programosy.pl/public_html/includes/utf/utf_tools.php on line 1663

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 112

Strict Standards: Non-static method utf_normalizer::nfkc() should not be called statically in /home/mati/domains/forum.programosy.pl/public_html/includes/utf/utf_tools.php on line 1663

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 112

Strict Standards: Non-static method utf_normalizer::nfkc() should not be called statically in /home/mati/domains/forum.programosy.pl/public_html/includes/utf/utf_tools.php on line 1663

Deprecated: preg_replace(): The /e modifier is deprecated, use preg_replace_callback instead in /home/mati/domains/forum.programosy.pl/public_html/includes/bbcode.php on line 112

Strict Standards: Non-static method utf_normalizer::nfkc() should not be called statically in /home/mati/domains/forum.programosy.pl/public_html/includes/utf/utf_tools.php on line 1663
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3900: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:483)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3902: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:483)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3903: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:483)
[phpBB Debug] PHP Notice: in file /includes/functions.php on line 3904: Cannot modify header information - headers already sent by (output started at /includes/bbcode.php:483)
linux. jak wykryć brak połączenia internetowego?? • programosy.pl

  • Ogłoszenie:

linux. jak wykryć brak połączenia internetowego??

Dyskusje i problemy z Unix'ami

Linux. Jak wykryć brak połączenia internetowego??

Postprzez uzi18 07 Lip 2005, 12:28

reklama
Witam serdecznie!

Mam modemik ADSL speedstream. Problem w tym ze on lubi sie co jakis czas wieszac. Jedynym sposobem (po zwisie) jest wylaczenie i wlaczenie modemu.
Wymyslilem sobie ze zbuduje uklad ktory po odebraniu sygnalu z portu drukarki wylaczy modem i pozniej na zadanie znow wlaczy.

Problem pozostal tylko w wykryciu faktu braku "netu"

myslalem nad :

1. ping-iem

np.
Kod: Zaznacz wszystko
ping -W 20 -c 1 onet.pl


2. wget :)

np.
Kod: Zaznacz wszystko
wget --tries 1 --timeout 50 http://www.onet.pl/favicon.ico



Moze jest na to jeszcze inny sposob? czekam na pomoc i propozycje.

Uklad jest zbudowany :
Pod D0 podlaczam 2 bramki NAND w szeregu ze zwartymi wejsciami a one wysterowuja tranzystor. Tan natomiast zalacza przekaznik ktory rozwiera napiecie zasilania modemu (18V).


Aktualnie skrypt wyglada tak (jak widac nie jest to ladnie napisane ;) ale dziala :) :

Kod: Zaznacz wszystko
#!/bin/sh

cd /tmp
wget --tries 1 --timeout 30 http://www.onet.pl/favicon.ico 2>/tmp/onet.log
rm -f /tmp/favicon.ico
test="`cat /tmp/onet.log | grep "saved"`"
rm -f /tmp/onet.log

if [ "$test" == "" ]; then
    date >/tmp/modem_log
    #wlacz linie D0 na LPT w stan wysoki
    /sbin/lpif -d /dev/parport0 -s 1 >/dev/null
    sleep 10
    /sbin/lpif -d /dev/parport0 -s 0 >/dev/null
fi
uzi18
~user
 
Posty: 4
Dołączenie: 07 Lip 2005, 11:46



Postprzez dark 07 Lip 2005, 13:20

Dość ciekawy sposób na restartowanie modemu :^)

Przeglądam skrypt i powiem, że użyłbym *ping* zamiast *wget'a*, ale jeżeli tak działa to dlaczego chcesz zmieniać?

Oczywiście skrypt dodałeś do *crontab'a*.

BTW ładniej jest poinformować dla jakiej powłoki jest napisany skrypt, czyli np.:
#!/bin/bash

Unikniesz problemów w przypadku zabawy ze zmianą linków.
Long Hard Road Out Of Hell...
Awatar użytkownika
dark
~user
 
Posty: 387
Dołączenie: 07 Maj 2005, 15:38
Miejscowość: Głogów
Pochwały: 10



Postprzez uzi18 07 Lip 2005, 18:54

Hej!
Kiedys uzywalem pinga ale tak mnie tknelo.

A WIEM!

Bo czasem sie dzialo tak ze niby ping dochodzil ... ,a internetu nie bylo :) (tak sie potrafi zawiesic tez)

Oczywiscie ladniej by bylo z wpisem "bash" :P

W miedzyczasie dojdzie jedna zmienna ;) "modem zresetowany" na wypadek gdyby sie okazalo ze skrypt goni skrypt i jeden wylacza modem drugi sprawdza i widzi ze nie ma netu i znow wylacza ;D :P albo ... co najciekawsze ... okazuje sie ze zresetowanie modemu nie przynosi skutku gdyz gdzies tam dalej ... powiedzmy urwal sie kabel w TPSA ;P albo jakis serwer padl np. DNS.

Oczywiscie wpis w cronie co powiedzmy 2 min. :)

BTW nie wymysle nic lepszego na reset modemu bez grzebania w nim ;P A moze jest jakis inny sposob?


Pozdrawiam

Ps. myslalem ze nikt nie odpisze ;D Dzieki.
uzi18
~user
 
Posty: 4
Dołączenie: 07 Lip 2005, 11:46



Postprzez dark 07 Lip 2005, 20:53

uzi18 napisał(a):Bo czasem sie dzialo tak ze niby ping dochodzil ... ,a internetu nie bylo :) (tak sie potrafi zawiesic tez)


Dlatego nie dajesz opcji jednego pakietu, tylko kilku :^)
Long Hard Road Out Of Hell...
Awatar użytkownika
dark
~user
 
Posty: 387
Dołączenie: 07 Maj 2005, 15:38
Miejscowość: Głogów
Pochwały: 10



Postprzez uzi18 09 Lip 2005, 21:22

Oto najnowsza wersja ktora nie resetuje ciagle modemu robi to jednorazowo i czeka na polaczenie (bo a noz widelec padl jakis serwer gdzies dalej albo kabelek sie urwal ;P )

Ping mial wyslac tylko 1 pakiet ;)
Za to uzywajac wget-a sprawdzam dns i polaczenie na port 80 czyli faktyczny "internet" dla coponiektorych w sieci.

Skrypt lekko zoptymalizowalem ;]

Czekam na opinie.
Pozdrawiam

Kod: Zaznacz wszystko
#!/bin/bash
# Autor: uzi18 malpa o2.pl

wget --tries 1 --timeout 30 -O /tmp/test_modemu http://www.onet.pl/favicon.ico 2>/tmp/onet.log

test="`cat /tmp/onet.log | grep "saved"`"
rm -f /tmp/onet.log

if [ "$test" == "" ]; then
    echo brak polaczenia
    if [ -e /tmp/reset_modemu ]; then
   echo modem byl juz zresetowany - brak polaczenia
   exit;
    else
   echo resetuje modem
   touch /tmp/reset_modemu
        echo -n "Utracono połączenie : " >>/home/www/modem_log
        date #>>/home/www/modem_log
        /sbin/lpif -d /dev/parport0 -s 1 >/dev/null
        sleep 3
        echo 3
        /sbin/lpif -d /dev/parport0 -s 0 >/dev/null;
    fi
elif [ -e /tmp/reset_modemu ]; then
    echo modem odzyskal polaczenie
    rm -f /tmp/reset_modemu
    echo -n "Odzyskano połączenie : " >>/home/www/modem_log
    date >>/home/www/modem_log
fi
uzi18
~user
 
Posty: 4
Dołączenie: 07 Lip 2005, 11:46



Postprzez dark 10 Lip 2005, 12:19

Pisanie skryptu polega na tym, by wydając jedno polecenie uzyskać kilka. W samym skrypcie nie powinno zamieszczać się zbędnych instrukcji.
Long Hard Road Out Of Hell...
Awatar użytkownika
dark
~user
 
Posty: 387
Dołączenie: 07 Maj 2005, 15:38
Miejscowość: Głogów
Pochwały: 10



Postprzez uzi18 10 Lip 2005, 19:57

Komentarze po ECHO byly/sa po to aby sasiad mogl zrozumiec co sie w ktorym momencie dzieje (pozniej je wytne) .
Skrypt funkcjonuje i w pon. moze wtorek uklad zacznie dzialac w polaczeniu z ukladem odcinania modemu ;]

Pozdrawiam
uzi18
~user
 
Posty: 4
Dołączenie: 07 Lip 2005, 11:46




Powróć do System Linux / Unix

Kto jest na forum

Użytkownicy przeglądający to forum: Brak zarejestrowanych użytkowników oraz 6 gości