I want to send the stdout and stderr of terminal while I run a huge batch file. The batch file echoer.sh
echo $HOME
sleep 3
echo $HOME
sleep 3
echo $HOME
# n times
Executing in terminal
./echoer.sh | redis-cli -x publish echoer
This waits for the entire execution of echoer.sh
to finish and then send the publish command. Is there a way to publish the output as soon as you receive it?
Current Output
# command
redis-cli subscribe echoer
# output below
1) "message"
2) "echoer"
3)"/home/prashant\n/home/prashant\n/home/prashant\n/home/prashant\n/home/prashant\n/home/prashant\n/home/prashant\n/home/prashant\n/home/prashant\n/home/prashant\n/home/prashant\n
Using xargs
, it sends each line to echoer
channel using xargs utility.
./echoer.sh| xargs -n 1 redis-cli publish echoer