SSH Remote Server issue

I have a script that connects to remote servers using a public key. Some of the servers are not set up for the public key and I receive the following when I attempt to ssh: The authenticity of host 'XXX' can't be established.
RSA key fingerprint is C4:6e:7e:37:38:3d:3a:0c:c1:42:d5:86:36:5f:b8:19.
Are you sure you want to continue connecting (yes/no)?

Is there anything I can put around my ssh so that when I receive this, I can just abort the attempt to connect?

That's because the server you try to connect to is not in your known_hosts file. I am not aware of a command that could check the existence of a host in that file other greping the file.

Edit:
try the option -F of the ssh-keygen command.

$ ssh-keygen -F hostname