I know the title is a bit confusing but here's my situation
#!/bin/bash
for node in `cat path/to/node.list`
do
echo "Checking node: $node"
ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no me@$node "nohup scriptXYZ.sh"
done
Basically scriptXYZ has an output. Something like: Node bla is Up or Node bla is Down. I want to do something that amounts to the following psudo code:
if (output_from_scriptXYZ == "Node bla is Up")
do this
else
do that
I've been trying to find a way to do this online but I couldn't find something that does this. Then again, I might not know what I'm searching for.
Also as a bonus: Is there any way to tell if the scriptXYZ has an error while it ran? Something like a "file does not exist" -- not the script itself but something the script tried to do and thus resulting in an error.
for node in $( cat file )...is much better writtenwhile read node; do ...; done < filefor x in $(cat y)semantics.