-1

I have something like this to do:

  1. I have an application that is made to take text like "a = 1" from stdin.
  2. Create a script for:
    • Create a pipe and redirect it to be stdin for application above,
    • Create second pipe, for user.
    • In loop:
      • Open second pipe and read.
      • After reaching the end send that to first one and ^E
      • Repeat.

I have done something like this and this doesn't work. There is problem with ambigious redirection (line 16) and wrong file descriptor (line 15). What's wrong?

mkfifo f1
mkfifo f2

p1 = /f1
p2 = /f2


exec 5<> $p1
./fifo -D $1 0<&5 &

while : ; do
    while read L ; do
        echo $L >&5
    done <$p2
    echo "5" >&5
done
whoan
  • 8,143
  • 4
  • 39
  • 48
metalowy
  • 101
  • 2
  • 11
  • I'm confused. Could you try to clarify a bit, perhaps with an example of input and expected output? You only want to run the program once, right? Is the point that you want to continue processing a new batch of input after End-Of-File? – amaurea Nov 23 '14 at 13:36
  • It takes lines like a=1, b=0 and evaluates expresion given in $1. Evaluation starts after ^E was sent and the it waits for new values. With EOF it stops. – metalowy Nov 23 '14 at 13:43
  • Either my reading comprehension is really low today, or you're being very sloppy with describing what you want this to do. What is supposed to terminate the inner loop if not EOF? Why do you specify `/f1` when the fifo you made was `f1`? What do you mean by "reaching the end" if you don't mean EOF? What is the `./fifo` command? How does what you want to do differ from a simple `while : ; do while read line; do echo $line; done; echo 5; done | yourprogram`? – amaurea Nov 23 '14 at 21:15
  • ./fifo is exactly my program. And hey, If I knew how does it work I wouldn't ask. These points in my question is exaclty what I was said to do. – metalowy Nov 24 '14 at 05:21
  • possible duplicate of [Unable to set variables in bash script in Mac OSX](http://stackoverflow.com/questions/2459286/unable-to-set-variables-in-bash-script-in-mac-osx) – tripleee Nov 24 '14 at 06:39

1 Answers1

0

You can't have spaces around the equals signs.

Please use http://shellcheck.net/ in the future.

tripleee
  • 175,061
  • 34
  • 275
  • 318