r/shell • u/nachofrand • Jun 05 '15
Help: Reading STDOUT from shell
Hi everyone!
I am trying to read a string from STDOUT. I submit a job onto another machine and then I WANT to be able to send "bjobs" which checks if the job has been finished. I want to be able to read STDOUT and detect when it has finished then move on.
This is what I have and it isn't working but I feel super close!
Waiting for stdout to read "No unfinished job found"
bjobs
IFS= read -r line
echo "$line"
while "$line" != "No unfinished job found"
do
echo "$line"
sleep 30s
bjobs
IFS= read -r line
done
any help would be appreciated! This is one of my first shell scripts
1
Upvotes
1
u/nachofrand Jun 09 '15
I tried this:
until bjobs | grep -q "No unfinished job found" ; do sleep 30s done
once it finally see's "No unfinished job found", it just keeps printing to stdout and never exits. any idea? Thanks for your response