[SOLVED] ssh external - error in function handler

Interested adding externals/plugins from LiveCode and third parties to your LiveCode projects? This is the place to talk about them.

Moderators: heatherlaine, Klaus, FourthWorld, robinmiller, kevinmiller

Post Reply
dbm
Posts: 21
Joined: Tue Feb 17, 2015 1:12 pm

[SOLVED] ssh external - error in function handler

Post by dbm » Tue Feb 17, 2015 1:29 pm

Hi,

I'm trying to use SSH External (from Trevor Devore github). If this code :

Code: Select all

on loginCheck
   local sUsername, sPassword, shost, sport, ssh_session, resultado, indice
   -- delete stack "rnacrockfordExternalWrapper"
   set the visible of the templateStack to false
   set the name of the templateStack to "rnacrockfordExternalWrapper"
   set the externals of the templateStack to "/home/myuserr/livecode/libs/ssh/binaries/livessh.so"
  create stack
start using stack "rnacrockfordExternalWrapper"
   put "userlogin" into sUsername
   put "passwordlogin" into sPassword
   put "sshhostip" into shost
   put "sshserverport" into sport
   put "Found these external functions" & cr & cr & the externalfunctions of stack "rnacrockfordExternalWrapper" into field "datos_ext"
   put ssh_new() into ssh_session
    ssh_options_set ssh_session, "host", shost
   ssh_options_set ssh_session, "port", sport
   ssh_connect ssh_session
   /*put ssh_userauth_password(ssh_session, sUsername, sPassword) into authResult*/
   put ssh_userauth_password(ssh_session, sUsername, sPassword) into resultado
   livessh_run_command ssh_session, "ls", "outVar"
   /* put outVar into field "LogField"*/
    ssh_disconnect ssh_session
   ssh_free ssh_session
end loginCheck
I get the following error when executing the card :

card "login": execution error at line 23 (Function: error in function handler) near "ssh_new", char 8

When running the ssh external github demo connection.livecode (sorry, my account hsa no rights to put web links) it works without problem.

I searched for a while in forums and the net without positive result (I think that ssh external is a very precious addon to livecode, but it's not well documented and seems that is not heavily used). This error is driving me mad 'cause all my livecode project is based in the ssh communication. Anyone could help me to understand the error root? Many thanks in advance, really.
Last edited by dbm on Mon Feb 23, 2015 6:29 pm, edited 1 time in total.

dbm
Posts: 21
Joined: Tue Feb 17, 2015 1:12 pm

Re: ssh external - error in function handler

Post by dbm » Tue Feb 17, 2015 1:56 pm

If I execute the demo

Code: Select all

on mouseUp
   local ssh_session
   put ssh_new() into ssh_session
   ssh_options_set ssh_session, "host", field "host"
   ssh_options_set ssh_session, "port", field "port"
   ssh_connect ssh_session
   put ssh_userauth_password(ssh_session, field "login", field "password") into authResult
   livessh_run_command ssh_session, "ls", "outVar"
   put outVar into field "LogField"
   ssh_disconnect ssh_session
   ssh_free ssh_session
end mouseUp
I get the error :
button "TestButton": execution error at line n/a (External handler: exception) near "Serious error"


but if I force to execute the next statements (F11) it works and connect, retrieving the expected data inside outVar (and LogField)


I don't undestand very well this behaviour

dbm
Posts: 21
Joined: Tue Feb 17, 2015 1:12 pm

Re: [SOLVED] ssh external - error in function handler

Post by dbm » Mon Feb 23, 2015 5:50 pm

I forgot to mark this thread as solved.

The external ssh runs ok, the errors came from a bad use of external declarations in my stacks.

If the external is well pointed, all calls to the libssh are ok and the application runs correctly.

I must do it better, but by now (as "fast&dirty" workaround for any other beginner like me with same problem) this method works well:

Add this code to your open card

Code: Select all

on openCard
   if exists (stack "rnacrockfordExternalWrapper") then delete stack "rnacrockfordExternalWrapper"
   set the visible of the templateStack to false
   set the name of the templateStack to "rnacrockfordExternalWrapper"
   set the externals of the templateStack to "/home/dballester/livecode/libs/ssh/binaries/livessh.so"
   create stack
   start using stack "rnacrockfordExternalWrapper"
   disable button "bsearch"
end openCard
I think that appliying the same logic in your own stack and openstack should have the same behaviour, but I'ven ot tested yet.

Post Reply

Return to “Using Externals and Plugins”