Here is a script I tried to write:
#!/bin/bash cat <&3 & # runs in background, takes input from file desc 3 echo "To Terminal" ... echo "To cat" 1>&3 echo "to cat again" 1>&3
Essentially I want my script to spawn a program (in this case, cat) and be able to send input to it through a file descriptor.
This doesn't work ("bad file descriptor"), I think because file descriptors must be associated with a real file. What I need then is to be able to create a permanent pipe with an associated descriptor (such as 3) that I can use to write to cat throughout the program. How can I do it?