I have a need to have a bash script communicate with another process, so I start my other process using Process Substitution and echo commands to it as such:
exec 3> >(cat)
echo "foo" >&3
exec 3>&-
exit
This is of course an oversimplification of what I'm doing but provides
for a very simple example.
The problem I'm running into is that the process that I am running in my
substitution can take a while to run and I want my main process to wait
for it to be done before it exits:
exec 3> >(sleep_10; cat)
/bin/echo "foo" >&3
/bin/echo \004 >&3 # just to illustrate that the cat should exit
here
exec 3>&-
# wait for cat to finish
exit
Other than playing some trickery in the substitution sub-shell to create
a file and then remove it on start and spinning in the main process
while the file exists, I can't find a way to synchronize the two
processes.
So this works:
exec 3> >(touch foo; sleep_10; cat; rm -f foo)
/bin/echo "foo" >&3
/bin/echo \004 >&3 # just to illustrate that the cat should exit
here
exec 3>&-
while [ -f foo ]; do
sleep 1
done
exit
But it's just so ugly.
For what it's worth, the process in the substitution is expect and what
I am feeding it from the script is an expect script.
Any ideas?
b.
--
My other computer is your Microsoft Windows server.
Brian J. Murrell
signature.asc
Description: This is a digitally signed message part
_______________________________________________ Bug-bash mailing list [email protected] http://lists.gnu.org/mailman/listinfo/bug-bash
