All pastes #389450 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-03-10 19:03 UTC
rendered paste body
#!/bin/bash


 
isAlive()
{ 
  for i in $*; do
     printf "GET /\n\n" | nc $i 80 > /dev/null 2>&1 && return 0
  done
  return 1
  
}

 gwAuxInUse=false
 isAlive google.com123
 alive=$?
 

 while : ; do
 
   if   [ $alive -eq 0 ] && $gwAuxInUse; then
        echo "cambiando a primario"
        gwAuxInUse=false
   elif [ $alive -eq 1 ] && ! $gwAuxInUse ; then
        echo "cambiando a secundario"
        gwAuxInUse=true
   fi       
 

sleep 10
done