Script de ping

eva evammg en gmail.com
Mar Mar 24 17:33:24 GMT 2009


>
> ------------------------------
>
> Message: 3
> Date: Mon, 23 Mar 2009 16:22:17 -0300
> From: "Ricardo Eureka!" <ricardoeureka en gmail.com>
> Subject: Re: Script de ping
> To: ubuntu-es en lists.ubuntu.com
> Message-ID:
>        <4c540db20903231222s404fbea3la0fb5116cfa9271d en mail.gmail.com>
> Content-Type: text/plain; charset=ISO-8859-1
>
> El 23/03/09, eva <evammg en gmail.com> escribió:
>>  Me ha encantado la forma de hacer el script, Ricardo, me harias el
>>  favor de explicar como funciona? Me encantaria que lo explicaras.
>>  la doble barra?, luego corchetes?, una tuberia (eso si lo entiendo),
>>  que redirige las salida para &2?
>>  desde luego si va bien (cuentanos, pepito!!!), me parece una forma de
>>  hacerlo muy elegante y limpia :D
>
> Hmmmm...muchas gracias, pero...nada que una visita por man bash no
> pueda enseñarte.
>
> Copio y pego las partes relacionadas, el resto del trabajo, hazlo tu ;)
>
> " An OR list has the form
>
>              command || command2
>
>       command2  is  executed  if  and  only if command returns a
>       non-zero exit status.  The return status  of  AND  and  OR
>       lists  is  the exit status of the last command executed in
>       the list."
> ....
>
> "       { list; }
>              list is simply executed in the current shell  envi-
>              ronment.   This  is  known as a group command.  The
>              return status is the exit status of list.
> "
> ....
>
> "REDIRECTION
>       Before a command is executed, its input and output may  be
>       redirected  using  a  special  notation interpreted by the
>       shell.  Redirection may also be used  to  open  and  close
>       files  for  the  current shell execution environment.  The
>       following redirection operators may precede or appear any-
>       where  within  a  simple  command or may follow a command.
>       Redirections are processed in the order they appear,  from
>       left to right.
>
>       In the following descriptions, if the file descriptor num-
>       ber is omitted, and the first character of the redirection
>       operator  is  <,  the  redirection  refers to the standard
>       input (file descriptor 0).  If the first character of  the
>       redirection  operator  is >, the redirection refers to the
>       standard output (file descriptor 1).
>
>       The word that follows the redirection operator in the fol-
>       lowing descriptions is subjected to brace expansion, tilde
>       expansion,  parameter  expansion,  command   substitution,
>       arithmetic  expansion,  quote removal, and pathname expan-
>       sion.  If it expands to more than one word,  bash  reports
>       an error.
>
>       Note  that  the order of redirections is significant.  For
>       example, the command
>
>              ls > dirlist 2>&1
>
>       directs both standard output and  standard  error  to  the
>       file dirlist, while the command
>
>              ls 2>&1 > dirlist
>
>       directs  only the standard output to file dirlist, because
>       the standard  error  was  duplicated  as  standard  output
>       before the standard output was redirected to dirlist.
> "
>
> Hay miles de tutoriales, HOWTOS, manuales, etc del elegante, sencillo
> y potente BASH por alli, esperando que lo descubras :D
>
> Suerte y bienvenido!!!!!
>
>
> --
> Ricardo A.Frydman
> Administrador Senior de Sistemas Unix
> Sun Certified System Administrator - Solaris 10
> http://unix-argentina.blogspot.com/
> http://www.warrenbuffet.com.ar
>
>
>
> ------------------------------

ping -c 1 remoto || { echo "remoto no responde a pings!!!"| mail
pepitovadecurt en gmail.com >&2 ; exit ; }


Hola,

Gracias Terra 1 por la web.

Ricardo, no hacia falta que copiaras al hacer un man hombre!! :)
Gracias! Ya veo cómo funciona.. pero es la primera vez que veo un OR
sin una condición (un if o un bucle) y por eso no me cuadraba. Me he
quedado muy 0_o con el script, es una manera de enfocar la idea muy
diferente a lo que estoy acostumbrada a ver. Tomo nota, eh? ^^
Y le echaré un vistazo a la web, Terra 1, que ya la miré por encima, y
tiene buena pinta.. esto engancha tela!!!

Saludos.

-- 
Departamento de Telemática y Desarrollo
Ministerio de Educación

Ubuntu User # 15094



Más información sobre la lista de distribución ubuntu-es