B4J Question [SSHJ] cannot execute shell command

ludogomez

Member
Licensed User
Longtime User
Hi,

I try to use SSHJ library and I have a problem :

this my code :

Test code:
#Region Project Attributes

    #MainFormWidth: 600

    #MainFormHeight: 600

#End Region


#PackagerProperty: VMArgs = --add-opens b4j/org.bouncycastle.jcajce.provider.asymmetric.ec=java.base

#MergeLibraries: False


#AdditionalJar: slf4j-api-1.7.25

#AdditionalJar: sshj-0.23.0

#AdditionalJar: eddsa-0.2.0

#AdditionalJar: bcprov-jdk15on-159


Sub Process_Globals

    Private fx As JFX

    Private MainForm As Form

    Private xui As XUI

    Private Button1 As B4XView

    Dim ssh1 As SSHJ

End Sub


Sub AppStart (Form1 As Form, Args() As String)

    MainForm = Form1

    MainForm.RootPane.LoadLayout("Layout1")

    MainForm.Show

End Sub


Sub Button1_Click


    ssh1.Initialize("ssh1")

    ssh1.AddHostKeyPromiscuousVerifier

    ssh1.AddAuthPassword("password")

    ssh1.Connectasync("server",22,"login")

    Wait For ssh1_ConnectionReady (Success As Boolean)

    Log(Success)
   

    Dim sf As Object = ssh1.Shell("/usr/bin/whoami", 1)

    Wait For (sf) ShellFinished(Success As Boolean, ShellCommandsExecuted As String, Output As String, Error As String)


    Log("Success = " & Success)

    Log("ShellCommandsExecuted = " & ShellCommandsExecuted)

    Log("Output = " & Output)

    Log("Error = " & Error)
      

End Sub

I can connect to the server, I have a true for the connectionReady, but I have no output from shell. I don't understand why the library can't execute my shell command.

Thanks
Regards
 
Top