I can let the sub run with the "all nodes" in the $node so just the tail will run and it works. If I put anything in $node I get nothing back. Even if the node is something that was returned in all nodes. My only other check was to remove the grep from the elseif line to make sure that the logic was working when $node is other than all nodes. and I get the same output as from the "all nodes" tail.
from command line I get what is expected.