[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: RES: [shell-script] Linhas
From: |
Thobias Salazar Trevisan |
Subject: |
Re: RES: [shell-script] Linhas |
Date: |
Thu, 24 Apr 2003 16:03:04 -0300 (BRT) |
ae rodolfo
On Thu, 24 Apr 2003, Rodolfo Villanova wrote:
> Fiz uns testes em bash no meu micro sob um Cygwin usando uns
> "echo $?" (que retorna "0" se houve sucesso na execucao do ultimo
> comando) logo apos pingar enderecos IPs alcancaveis e nao
> alcancaveis, e a resposta foi sempre a mesma: 0.
O código que os comandos UNIX retornam não estão relacionados com
o bash. o que o bash faz é só colocar este código no $?
Como você testou no cygwin, a implementação do SO é diferente, e
assim o mesmo não ocorre. Olhe só:
$ man ping
....
If ping does not receive any reply packets at all it will exit
with code 1. If a packet count and deadline are both
specified, and fewer than count packets are received by the time
the deadline has arrived, it will also exit with code 1.
On other error it exits with code 2. Otherwise it exits with code 0.
This makes it possible to use the exit code to see if a host is
alive or not.
....
$ ping -c1 -w1 aluminio; echo $?
PING aluminio (127.0.0.1) from 127.0.0.1 : 56(84) bytes of data.
64 bytes from aluminio (127.0.0.1): icmp_seq=1 ttl=64 time=0.049
ms
--- aluminio ping statistics ---
1 packets transmitted, 1 received, 0% loss, time 0ms
rtt min/avg/max/mdev = 0.049/0.049/0.049/0.000 ms
0
$ ping -c1 -w1 ouro; echo $?
PING ouro (10.10.10.140) from 10.10.10.156 : 56(84) bytes of
data.
--- ouro ping statistics ---
1 packets transmitted, 0 received, 100% loss, time 0ms
1
$ ping -c1 -w1 adasddas; echo $?
ping: unknown host adasddas
2
falow
thobias
-------
echo 24883721290304465999833114447114149701898P | dc
-------
http://www.lcp.coppe.ufrj.br/~thobias
____________________________
|
| Against - HTML Mail
| Against - MS ATTACHMENTS
|
----------------------------