From: superpollo on 21 May 2010 12:07 Ed Morton ha scritto: > On 5/21/2010 9:43 AM, superpollo wrote: >> Ben Finney ha scritto: >>> superpollo <utente(a)esempio.net> writes: >>> >>>> is it possible to crete a "text file" such that it has a different >>>> content each time it is opened? >>> >>> Not as a text file. >>> >>> Two existing patterns that I can think of: >>> >>> * Write a program to generate the output. Run that program. >>> >>> * Write a program to generate the output on a named pipe (see the Linux >>> man page 'fifo(7)', or any Unix documentation about FIFOs). Run that >>> program. Read the named pipe when you want the output. >>> >> >> ok, i tried this: >> >> >> $ cat fifo.sh >> #!/usr/bin/env bash >> [ -p "numbers" ] || mkfifo "numbers" >> for i in $(seq 1 1 10) >> do >> echo $i >> numbers >> done >> $ ./fifo.sh & >> [1] 7946 >> $ cat numbers >> 1 >> 2 >> 3 >> 4 >> 5 >> 6 >> 7 >> 8 >> 9 >> 10 >> [1]+ Done ./fifo.sh >> $ >> >> but i expecter something like: >> >> $ cat numbers >> 1 >> $ cat numbers >> 2 >> $ cat numbers >> 3 >> ... > > change ">>" to ">" ~/superpollo$ cat fifo.sh #!/usr/bin/env bash [ -p "numbers" ] || mkfifo "numbers" for i in $(seq 1 1 10) do echo $i > numbers done ~/superpollo$ ./fifo.sh & [1] 8989 ~/superpollo$ cat numbers 1 2 3 4 5 6 7 8 9 10 [1]+ Done ./fifo.sh ~/superpollo$
From: Bill Marcum on 21 May 2010 12:26 On 2010-05-21, superpollo <utente(a)esempio.net> wrote: > Ed Morton ha scritto: >>> but i expecter something like: >>> >>> $ cat numbers >>> 1 >>> $ cat numbers >>> 2 >>> $ cat numbers >>> 3 >>> ... >> >> change ">>" to ">" > > ~/superpollo$ cat fifo.sh > #!/usr/bin/env bash > [ -p "numbers" ] || mkfifo "numbers" > for i in $(seq 1 1 10) > do > echo $i > numbers > done > ~/superpollo$ ./fifo.sh & > [1] 8989 > ~/superpollo$ cat numbers > 1 > 2 > 3 > 4 > 5 > 6 > 7 > 8 > 9 > 10 > [1]+ Done ./fifo.sh > ~/superpollo$ for i in $(seq 1 10) do echo $i > numbers sleep 1 done
From: superpollo on 21 May 2010 14:02 Bill Marcum ha scritto: > On 2010-05-21, superpollo <utente(a)esempio.net> wrote: >> Ed Morton ha scritto: >>>> but i expecter something like: >>>> >>>> $ cat numbers >>>> 1 >>>> $ cat numbers >>>> 2 >>>> $ cat numbers >>>> 3 >>>> ... >>> change ">>" to ">" >> ~/superpollo$ cat fifo.sh >> #!/usr/bin/env bash >> [ -p "numbers" ] || mkfifo "numbers" >> for i in $(seq 1 1 10) >> do >> echo $i > numbers >> done >> ~/superpollo$ ./fifo.sh & >> [1] 8989 >> ~/superpollo$ cat numbers >> 1 >> 2 >> 3 >> 4 >> 5 >> 6 >> 7 >> 8 >> 9 >> 10 >> [1]+ Done ./fifo.sh >> ~/superpollo$ > > for i in $(seq 1 10) > do > echo $i > numbers > sleep 1 > done > thanks! -- chiedo scusa a chi e' offeso. il mio era un messaggio bonario.
First
|
Prev
|
Pages: 1 2 Prev: Why am I still being prompted for a password? Next: What am I missing here? |