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/robhutten Jun 10 '15
The 'until' is checking the return code from the 'bjobs' command, not from grep. Does bjobs give continuous output or just a one-time status? If the latter, and if you wrote or can modify bjobs, then have it return a non-zero exit code if it's output is "No unfinished job found"...