if /home/script/myscript.py | grep -q PASS;
then
echo "we can proceed"
else
echo "we cannot"
fi
Unfortunately, It did not worked..
as It it did not prompt anything ( As, when the script is run - then it prompt for user and password, and when then input is provided - It checks in the portal ( whose credentials we have given ) and return back if found in inventory ]
So, What i have thought is
run the script and provide username and password and when the o/p is given PASS or FAIL - I should take the o/p in a file and grep PASS or FAIL from that...
Now, the issue how to redirect the script o/p to a temporary file....
If you pipe the output to grep (or anything), of course nothing can be prompted to e.g. the screen. Are you able to modify the script? Then prompt to another file descriptor pointing to the screen.
Still the output PASS should be detected by grep and the evaluation thereafter should be OK.
It really would be preferable if you could the one who maintains the script if they could add a return code, then you could try:
if script; then
echo "we can proceed"
else
echo "we cannot"
fi
If not, you could try something like:
script |
{
found=false
while read answ
do
printf "%s\n" "$answ"
case $answ in
(*PASS*) found=true
esac
done
if $found; then
echo "we can proceed"
else
echo "we cannot"
fi
}
-- edit --
Indeed in the second case, RudiC's idea would probably be a better suggestion:
if script | tee /dev/tty | grep -q PASS; then
echo "we can proceed"
else
echo "we cannot"
fi