shell-script-pt
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

timeout com telnet no shell


From: Augusto, Alexandre
Subject: timeout com telnet no shell
Date: Mon, 24 Jan 2005 06:58:19 -0600

Pessoal,
Escrevi um script que tem a intenção de testar se um serviço está ouvindo
ou não em determinada porta.
Meu problema é que a linha que diz a ele cancelar o telnet se a conexão não
Estiver ok não está funcionando.
Alguém pode ajudar ?

Segue o script:


trap 'echo "esse script foi parado com <CTRL+C> ... " ; exit 1' 1 2 3 15
UNAME=$(uname)
PINGCOUNT=2
PACKETSIZE=56
#DIR=$(pwd)
HOSTLIST="hostlist.txt"
PINGSTAT=""
PINGSTAT2=""
ESTEHOST=$UNAME
SAIDA="ping_log"
integer  INTERVAL=1
function telnet_ops
{
#Comeca o teste do telnet

TELPORT2="8080"
TELPORT3="5020"
TELPORT4="3001"
TELPORT18="4040"
LOG="telnet_log.txt"
         for HOSTPING in `cat ${HOSTLIST} | xargs`
         do
             for TELPORT in $(echo $TELPORT2 $TELPORT3 $TELPORT4 $TELPORT18)
             do
                   echo "tentando telnet nas portas --> ${TELPORT}"
                        (sleep 1 ; echo \033 ; sleep 1 ; echo quit) | telnet
$HOSTPING $TELPORT > /dev/null 2> $LOG
                             if [ -z "`grep refused $LOG`" ]; then
                   echo " *** A conexão na porta$TELPORT no servidor
$HOSTPING está OK ***"
                                  else
                   echo " *** A conexão na porta$TELPORT no servidor
$HOSTPING está  NOT OK ***"
                             fi
              done
        done
}
telnet_ops

Obrigado, 

Alexandre




reply via email to

[Prev in Thread] Current Thread [Next in Thread]