Script de ping
Ricardo Eureka!
ricardoeureka en gmail.com
Lun Mar 23 19:22:17 GMT 2009
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
Más información sobre la lista de distribución ubuntu-es