I've created a function that tries to connect to an ssh server (code below). The login/password are typed by the user in a card and my idea was to validate the login/password to answer if they were correct or not.
If the login/password are correct, the ssh_userauth_password returns "OK" but if intentionaly I type an incorrect user or password i get
execution error at line n/a (External handler: exception) near "Authentication failed"
I was expecting a ssh_userauth_password return similar to a negative answer "no OK" or something like this, but not a external handler exception.
Has Livecode a way to process the external handler exceptions or is it the expected behavior?
Code: Select all
function test_ssh_login sshuser sshpass sshost ssport
local outVar, ssh_stat, ssh_session
put ssh_new() into ssh_session
ssh_options_set ssh_session, "host", sshost
ssh_options_set ssh_session, "port", ssport
ssh_connect ssh_session
put ssh_userauth_password(ssh_session, sshuser, sshpass) into ssh_stat
ssh_disconnect ssh_session
ssh_free ssh_session
return ssh_stat
end test_ssh_login