1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Please Help With InternetCheck.sh

Discussion in 'Tomato Firmware' started by devlin016, Oct 16, 2010.

  1. devlin016

    devlin016 Addicted to LI Member

    im not good at linux scripting please help whats wrong with this

    ping -c 1 www.google.com > /dev/null
    if [[ $? -ne 0 ]]; then
    led white off
    led amber on
    echo Warning No Internet Connectivity!
    logger Warning No Internet Connectivity!
    fi
    if ping -c 1 www.google.com > /dev/null; then
    led amber off
    led white on
    echo Conectivity Established!
    logger Conectivity Established!
    fi
    ping -c 1 192.168.0.1 > /dev/null
    if [[ $? -ne 0 ]]; then
    led amber on
    led white on
    echo Warning Modem Not Connected!
    logger Warning Modem Not Connected!
    fi
     
  2. Porter

    Porter LI Guru Member

    I'm certainly not very knowledgable either but the stuff your are looking for are loops: http://en.wikipedia.org/wiki/Control_flow#Loops

    Apart from that it's great to code things yourself, but in this case there definitely are many tutorials around or you could just search for that bash script. Just remember to change the first line from #/bin/bash to #/bin/sh .

    Good luck!
     
  3. devlin016

    devlin016 Addicted to LI Member

    thanks for the reply but i absoutly suck at linux commands its like reading another laugange to me :(
     
  4. srouquette

    srouquette Network Guru Member

    I didn't test it, but you can try something like this.
    I think the only useful information is WAN Up.

    In Init:
    Code:
    led amber on
    while sleep 3; do
    if ! ping -c1 -w1 google.com | grep -q from; then
    led white off
    fi
    done
    
    In WAN Up:
    Code:
    led white on
    
     
  5. devlin016

    devlin016 Addicted to LI Member

    thanks but my wan up doesnt work so it has to go in my init and i want my amber of if no conectivity and white on if there is and if possiable if it cant ping my modem blink white and amber at the same time
     
  6. karogyoker

    karogyoker Addicted to LI Member

    I recommend this page:
    http://lowfatlinux.com/

    Don't test the whole code at first, just little parts of it, and if they work then put them together.
     

Share This Page