Provide arguments (via bash script) to a process that is already running
bash
Solution
You can use an anonymous pipe:
# open a new file descriptor (3) and provide as stdin to myapp
exec 3> >(run myapp)
# do some stuff ....
# write arguments to the pipe
echo "arg1 arg2 -arg3 ..." >&3
The advantage over a named pipe is the fact that you don't need to worry about cleaning up and you won't need any write permissions.
Problem
I'm trying to have a bash script that does the following (in pseudocode): ``` #!/bin/bash run myapp (which needs arguments given from stdin) /* do some extra stuff */ provide arguments to hanging process myapp ``` For example, say you run myapp, and after it runs it asks for your name. I.e., I run it via bash, but I don't want to give it a name just yet. I just want it to run for now, while in the meantime bash does some other stuff, and then I want to provide my name (still via bash). How do I do this?