[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [shell-script] erro " too many arguments" ???
From: |
Flavio Junior |
Subject: |
Re: [shell-script] erro " too many arguments" ??? |
Date: |
Thu, 29 Nov 2007 13:22:11 -0200 |
Coloque o "$respA" entre aspas..
Mas há formas melhor de fazer esse teste, usando o return code..
Veja o $?
Flavio do Carmo Junior
On Nov 29, 2007 1:20 PM, bossonaroesao06 <address@hidden> 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
>
>