Reputation: 23
I have a gateway bash script. The data being sent to STDERR is the data I want to pipe to the stdin of a application started by the bash script (a nodejs script).
Here is an idea of what I'm trying to do... bash-gateway.sh:
#since STDERR will not continuously send data, i put a neverending while loop
#to wait for data to be present.
while (true);
do
#Read the data from STDERR and send it to server.js STDIN
cat /dev/fd/2 | node server.js;
done;
Upvotes: 1
Views: 320
Reputation: 1
You haven't really said what is sending the Bash script the information. So I will assume it to be the program foo
for the purpose of this answer. Having said that, you should be able to do something like this if you
just need STDERR
foo 2>&1 >/dev/null | node server.js
if you don't mind piping both STDERR and STDOUT this would be simpler
foo |& node server.js
Upvotes: 1
Reputation: 7802
That is what pipes were made for.
mkfifo needed_stderr
somecommand 2>needed_stderr
node server.js <needed_stderr
Upvotes: 1