potrzebuję zrobić powiadomienie na wypadek braku internetu.
Przejrzałem internet i na elektrodzie znalazłem taki skrypt:
Kod: Zaznacz cały
[color=#666666][I]#!/bin/sh[/I][/color]
[color=#666666][I]# ustawienia[/I][/color]
[color=#007800]HOST[/color]=[color=#007800]$1[/color]
[color=#007800]PARAMETR[/color]=[color=#007800]$2[/color]
[color=#007800]ADMINTEL[/color]=[color=#FF0000]"48XXXXXXXXX"[/color]
[color=#007800]ADMINMAIL[/color]=[color=#FF0000]"admin@jakis_serwer.pl"[/color]
[color=#007800]LOG[/color]=[color=#FF0000]"./pingtest.log"[/color]
[color=#666666][I]# tworzenie pliku logow, jesli nie istnieje[/I][/color]
[color=#000000][B]if[/B][/color] [color=#7A0874][B][[/B][/color] [color=#000000][B]![/B][/color] [color=#660033]-e[/color] [color=#007800]$LOG[/color] [color=#7A0874][B]][/B][/color] [color=#000000][B]then[/B][/color]
[color=#C20CB9][B]touch[/B][/color] [color=#007800]$LOG[/color]
[color=#000000][B]fi[/B][/color]
[color=#666666][I]# funkcja wysylajaca sms pod podany w ustawieniach numer[/I][/color]
[color=#000000][B]function[/B][/color] sms [color=#7A0874][B]{[/B][/color]
[color=#7A0874][B]{[/B][/color]
[color=#7A0874][B]echo[/B][/color] From: powiadomienia[color=#000000][B]@[/B][/color]jakis_serwer.pl
[color=#7A0874][B]echo[/B][/color] To: [color=#007800]$ADMINTEL[/color][color=#000000][B]@[/B][/color]text.plusgsm.pl
[color=#7A0874][B]echo[/B][/color]
[color=#7A0874][B]echo[/B][/color] [color=#000000][B]`[/B][/color][color=#C20CB9][B]date[/B][/color] [color=#FF0000]'+%d/%m/%Y %H:%M:%S'[/color][color=#000000][B]`[/B][/color] [color=#FF0000]":: Host [color=#000099][B]\"[/B][/color][color=#007800]$HOST[/color][color=#000099][B]\"[/B][/color] nie odpowiada na pingi"[/color]
[color=#7A0874][B]echo[/B][/color] .
[color=#7A0874][B]echo[/B][/color] quit
[color=#7A0874][B]}[/B][/color] [color=#000000][B]|[/B][/color] [color=#000000][B]/[/B][/color]usr[color=#000000][B]/[/B][/color]sbin[color=#000000][B]/[/B][/color][color=#C20CB9][B]sendmail[/B][/color] [color=#660033]-t[/color]
[color=#7A0874][B]}[/B][/color]
[color=#666666][I]# funkcja wysylajaca e-mail pod adres podany w ustawieniach[/I][/color]
[color=#000000][B]function[/B][/color] email [color=#7A0874][B]{[/B][/color]
[color=#7A0874][B]{[/B][/color]
[color=#7A0874][B]echo[/B][/color] Awaria:
[color=#7A0874][B]echo[/B][/color]
[color=#7A0874][B]echo[/B][/color] [color=#000000][B]`[/B][/color][color=#C20CB9][B]date[/B][/color] [color=#FF0000]'+%d/%m/%Y %H:%M:%S'[/color][color=#000000][B]`[/B][/color] [color=#FF0000]":: Host [color=#000099][B]\"[/B][/color][color=#007800]$HOST[/color][color=#000099][B]\"[/B][/color] nie odpowiada na pingi"[/color]
[color=#7A0874][B]}[/B][/color] [color=#000000][B]|[/B][/color] mutt [color=#660033]-s[/color] [color=#FF0000]"Awaria"[/color] [color=#660033]-a[/color] [color=#007800]$LOG[/color] [color=#007800]$ADMINMAIL[/color] [color=#7A0874][B]}[/B][/color]
[color=#666666][I]# wypuszczenie pieciu pingow, wynik przypisz do zmiennej wynik[/I][/color]
[color=#C20CB9][B]ping[/B][/color] [color=#007800]$1[/color] [color=#660033]-c5[/color] [color=#660033]-w5[/color] [color=#000000][B]|[/B][/color] [color=#C20CB9][B]grep[/B][/color] [color=#FF0000]'ttl'[/color] [color=#000000][B]>[/B][/color] [color=#000000][B]/[/B][/color]dev[color=#000000][B]/[/B][/color]null [color=#7A0874][B]let[/B][/color] [color=#007800]wynik[/color]=[color=#007800]$?[/color]
[color=#666666][I]# jesli ping dojdzie (wynik 0)...[/I][/color]
[color=#000000][B]if[/B][/color] [color=#7A0874][B][[/B][/color] [color=#007800]$wynik[/color] [color=#660033]-eq[/color] [color=#000000]0[/color] [color=#7A0874][B]][/B][/color]; [color=#000000][B]then[/B][/color]
[color=#7A0874][B]echo[/B][/color] ok [color=#000000][B]>[/B][/color] [color=#000000][B]/[/B][/color]dev[color=#000000][B]/[/B][/color]null
[color=#666666][I]# zapisz informacje do logow[/I][/color]
[color=#7A0874][B]echo[/B][/color] [color=#000000][B]`[/B][/color][color=#C20CB9][B]date[/B][/color] [color=#FF0000]'+%d/%m/%Y %H:%M:%S'[/color][color=#000000][B]`[/B][/color] [color=#FF0000]":: Host [color=#000099][B]\"[/B][/color][color=#007800]$HOST[/color][color=#000099][B]\"[/B][/color] odpowiada na pingi"[/color] [color=#000000][B]>>[/B][/color] [color=#007800]$LOG[/color]
[color=#666666][I]# jesli ping nie dojdzie (wynik 1)[/I][/color]
[color=#000000][B]else[/B][/color]
[color=#666666][I]# zapisz informacje do logow[/I][/color]
[color=#7A0874][B]echo[/B][/color] [color=#000000][B]`[/B][/color][color=#C20CB9][B]date[/B][/color] [color=#FF0000]'+%d/%m/%Y %H:%M:%S'[/color][color=#000000][B]`[/B][/color] [color=#FF0000]":: Host [color=#000099][B]\"[/B][/color][color=#007800]$HOST[/color][color=#000099][B]\"[/B][/color] nie odpowiada na pingi"[/color] [color=#000000][B]>>[/B][/color] [color=#007800]$LOG[/color]
[color=#000000][B]if[/B][/color] [color=#7A0874][B][[/B][/color] [color=#FF0000]"[color=#007800]$PARAMETR[/color]"[/color] [color=#000000][B]![/B][/color]= [color=#FF0000]""[/color] [color=#7A0874][B]][/B][/color]; [color=#000000][B]then[/B][/color]
[color=#666666][I]# badanie drugiego parametru, domyslnie slij e-mail[/I][/color]
[color=#000000][B]if[/B][/color] [color=#7A0874][B][[/B][/color] [color=#007800]$PARAMETR[/color] = [color=#FF0000]"email"[/color] [color=#7A0874][B]][/B][/color]; [color=#000000][B]then[/B][/color]
email
[color=#000000][B]elif[/B][/color] [color=#7A0874][B][[/B][/color] [color=#007800]$PARAMETR[/color] = [color=#FF0000]"sms"[/color] [color=#7A0874][B]][/B][/color]; [color=#000000][B]then[/B][/color]
sms
[color=#000000][B]elif[/B][/color] [color=#7A0874][B][[/B][/color] [color=#007800]$PARAMETR[/color] = [color=#FF0000]"email+sms"[/color] [color=#7A0874][B]][/B][/color]; [color=#000000][B]then[/B][/color]
email
sms
[color=#000000][B]else[/B][/color]
[color=#7A0874][B]echo[/B][/color] [color=#000000][B]`[/B][/color][color=#C20CB9][B]date[/B][/color] [color=#FF0000]'+%d/%m/%Y %H:%M:%S'[/color][color=#000000][B]`[/B][/color] [color=#FF0000]":: Bledny parametr przy badaniu hosta [color=#000099][B]\"[/B][/color][color=#007800]$HOST[/color][color=#000099][B]\"[/B][/color]: [color=#007800]$PARAMETR[/color] (wysylam e-mail)"[/color] [color=#000000][B]>>[/B][/color] [color=#007800]$LOG[/color]
email
[color=#000000][B]fi[/B][/color]
[color=#000000][B]else[/B][/color]
[color=#7A0874][B]echo[/B][/color] [color=#000000][B]`[/B][/color][color=#C20CB9][B]date[/B][/color] [color=#FF0000]'+%d/%m/%Y %H:%M:%S'[/color][color=#000000][B]`[/B][/color] [color=#FF0000]":: Nie podano parametru przy badaniu hosta [color=#000099][B]\"[/B][/color][color=#007800]$HOST[/color][color=#000099][B]\"[/B][/color] (wysylam e-mail)"[/color] [color=#000000][B]>>[/B][/color] [color=#007800]$LOG[/color]
email
[color=#000000][B]fi[/B][/color]
[color=#000000][B]fi[/B][/color]
./pingtest.sh: 13: ./pingtest.sh: Syntax error: "fi" unexpected (expecting "then")
Nie wiem co może być tego przyczyną.
Proszę o pomoc.
Z góry dziękuję.