[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: pipe como variable en bash



a mi se me ocurre 

export variable="$(rtl_fm -f 433500000 -s 200000 -r 96000 -g 19.7 2>/dev/null | Efergy)";

y ya podrias usar la variable dentro de MiScript.sh

On Sun, Feb 4, 2018 at 3:34 PM, fernando sainz <fernandojose.sainz@gmail.com> wrote:
El día 4 de febrero de 2018, 21:32, Josu Lazkano
<josu.lazkano@gmail.com> escribió:
> Buenas,
>
> Tengo un pequeño problema de scripting que no se como resolver.
> Dispongo de un comando que me da el consumo eléctrico de mi casa:
>
> # rtl_fm -f 433500000 -s 200000 -r 96000 -g 19.7 2>/dev/null | Efergy
>
> Lo que quiero es redirigir esta salida a un script en bash y tratar la
> salida como una variable. Algo así:
>
> # rtl_fm -f 433500000 -s 200000 -r 96000 -g 19.7 2>/dev/null | Efergy
> | MiScript.sh
>
> El problema es que no se como capturar la variable, he probado con
> "$1" pero solo sirve para argumentos.
>
> ¿Alguien me pude ayudar?
>
> Gracias por todo y un saludo.
>
> --
> Josu Lazkano
>

No entiendo muy bien lo que preguntas.
Creo que podrías poner en tu script llamadas a "read" (man bash) que
lee una linea de la entrada estándar.


       read [-ers] [-a aname] [-d delim] [-i text] [-n nchars] [-N nchars] [-p
       prompt] [-t timeout] [-u fd] [name ...]
              One line is read from the  standard  input,  or  from  the  file
              descriptor  fd supplied as an argument to the -u option, and the
              first word is assigned to the first name, the second word to the
              second  name, and so on, with leftover words and their interven‐
              ing separators assigned to the last name.  If  there  are  fewer
              words read from the input stream than names, the remaining names
              are assigned empty values.  The characters in IFS  are  used  to
              split  the  line  into words using the same rules the shell uses
              for expansion (described above under Word Splitting).  The back‐
              slash  character  (\)  may be used to remove any special meaning
              for the next character read and for line continuation.  Options,
              if supplied, have the following meanings:

S2.




--
"Cada cual según sus fuerzas, cada quien según sus necesidades..."

Reply to: