ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

Help / WLanguage / WLanguage functions / Communication / SSH functions
  • Keeping SSH sessions alive
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
Sends a command to an SSH server. The session is automatically started and closed as soon as the command is sent.
Example
cMySession is sshSession
cMySession.Address = "127.0.0.1"
cMySession.Port = 22
cMySession.User = "login"
cMySession.UserPassword = "pass"
nExitCode is int
sOutput is ANSI string
sOutputErr is ANSI string
(nExitCode, sOutput, sOutputErr) = SSHCommand(cMySession, EDT_Command)
IF ErrorOccurred THEN
	Error(ErrorInfo(errFullDetails))
	RETURN
END
EDT_ExitCode = nExitCode
EDT_StdOut = UTF8ToString(sOutput)
EDT_StdErr = UTF8ToString(sOutputErr)
cMySession is sshSession
cMySession.Address = "127.0.0.1"
cMySession.User = "login"
cMySession.UserPassword = "pass"

bufDataSent is Buffer = 'It's [%TimeToString(TimeSys, "HH:mm:SS")%]'
nExitCode is int
sOutput is ANSI string
sOutputErr is ANSI string

// Execute a Linux script that stores sent data in a file 
// then displays the file contents on standard output
(nExitCode, sOutput, sOutputErr) = SSHCommand(cMySession, ...
	"echo $(</dev/stdin) > data_sent.txt; cat data_sent.txt", bufDataSent)
Trace(sOutput) //Displays the content of bufStandardInput
Syntax
(<Result>, <Data received>, <Data if error>) = SSHCommand(<SSH session> , <Command> [, <Data to send>])
<Result>: Integer
Exit code of the command.
<Data received>: Buffer
Data received from the server.
<Data if error>: Buffer
Data received from the server if an error occurs.
<SSH session>: sshSession variable
Name of the sshSession variable corresponding to the SSH session on which the command must be run.
<Command>: Character string
Command that must be sent to the SSH server.
<Data to send>: Optional buffer
Data that must be sent to the server. This data can be read in the standard input (stdin).
Remarks
New in version 2025

Keeping SSH sessions alive

You can keep SSH sessions alive (KeepAliveInterval property of the sshSession variable). This method consists in sending two requests to the server at given intervals, in order to keep the connection alive and to check that the server is still responding. The KeepAliveInterval property sets the duration between these two requests.
If the SSH server shuts down unexpectedly while a long command initiated by SSHCommand is being executed, the keep alive functionality can detect the loss of connection between the application and the server.
Business / UI classification: Business Logic
Component: wd300com.dll
Minimum version required
  • Version 20
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/20/2024

Send a report | Local help