### About

Various B4J examples of running remotely, from other devices, Raspberry Pi commands.
Other devices could be like from Windows, another Raspberry Pi or Android.
The B4J examples make use of the library jkSSH2.
See https://www.b4x.com/android/forum/threads/libary-jkssh2-ssh2-communication-in-b4a.20048/#post-307308) .
Many thanks to the developer for making this great library available.
Ensure to copy the library jkssh2.jar & xml to the B4J additional libraries folder.
Important
1. Set debugoutput to false as debugging not supported by B4J. Debugging is by default using android/utils.
SSH.DebugOutput = False
2. Do not use http:// prefix for the hostname.
Correct: Private hostname As String = "192.168.0.16"
Wrong: Private hostname As String = "http://192.168.0.16"
3. Use the full path to a file
Correct: "/home/pi/b4j/domotocztofirebase.log"
Wrong: "/b4j/domotocztofirebase.log"
Example B4J Non-UI App Reading the Raspberry Pi CPU Temperature
#Region Project Attributes
#CommandLineArgs:
#MergeLibraries: True
#End Region
`Sub Process_Globals
Private SSH As jkSSH2
Private hostname As String = "192.168.0.16"
Private port As Int = 22
Private username As String = "pi"
Private password As String = "*******"
Private command As String = "cat /sys/class/thermal/thermal_zone0/temp"
End Sub`
`Sub AppStart (Args() As String)
SSH.Initialize("SSH", hostname, port)
SSH.authenticateWithPassword(username, password)
SSH.DebugOutput = False
SSH.execCommand(command, port)
StartMessageLoop
End Sub`
`Sub SSH_CmdExecuted (Success As Boolean, Result As List, TaskId As Int)
Log($"SSH Command Executed. Result: ${Success}"$)
For Each s As String In Result
Log(s)
Next
End Sub`
Output
SSH Command Executed. Result: true
35399
Note: The returned temperature has to be divided by 1000.

Changed: , Category: Raspberry Pi Remote Control, File: T6C237M1729.htm, ID: 1729