FTP to SFTP conversion

Hi,
I have the following ftp code to check the status of communication channel :

/bin/ftp -i -v -n -B 64 $HOST <<END 2>&1 > $LOGFILE
user $user $password
bye
END

I need to re write to use SFTP, I know how to do SFTP with authentication keys.
But my problem is, when the authentication fails, it asks for the password, which I dont want, else I need to write the error in the $LOGFILE.

Could you please explain me how to do it, without using script file for SFTP

Regards
Shihab