|
From: | Fábio Gomes |
Subject: | Re: [shell-script] erro " too many arguments" ??? |
Date: | Thu, 29 Nov 2007 13:55:16 -0200 |
User-agent: | Thunderbird 2.0.0.9 (X11/20071031) |
bossonaroesao06 wrote:
Sou iniciante e, shell e to fazendo um script que verifica se minha internet ta pingando e escreve isso em um arquivo de log. Aparentemente ta correto mas encontrei o seguinte erro ao executar: [root@localhost ~]# ./teste.sh ./teste.sh: line 4: [: too many arguments Olha o script: #!/bin/bash respA=$(ping -c 1 200.204.0.10 | grep "1 received") dt=$(date) if [ -z $respA ] then echo "nao esta respondendo em : $dt" >> /root/log.txt else echo "esta respondendo em : $dt" >> /root/log.txt fi exit Por que deu esse erro na linha do IF? Obrigado
Testa o fping ( http://fping.sf.net ) Veja: $fping 200.204.0.10 200.204.0.10 is alive $fping 200.204.0.333 200.204.0.333 address not found$fping 200.204.0.1 200.204.0.1 is unreachable
O ruim do fping é que você não consegue dizer por qual interface o ping irá sair, no caso o ping você usa o parâmetro -I.
Fábio Gomes dos Santos
[Prev in Thread] | Current Thread | [Next in Thread] |