Test successfull ssh login

On Ubuntu, you would need the sshpass tool to supply a cleartext password on the command line (which is frowned upon, btw.). I don’t know about other OSes. Is that what you are looking for? Can’t you use ssh keys?
And yes, I reckon you have to write such a check yourself.