|
|
|
|
|
- Keeping SSH sessions alive
SSHCommand (Function) In french: SSHCommande Sends a command to an SSH server. The session is automatically started and closed as soon as the command is sent. 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
(nExitCode, sOutput, sOutputErr) = SSHCommand(cMySession, ...
"echo $(</dev/stdin) > data_sent.txt; cat data_sent.txt", bufDataSent)
Trace(sOutput)
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 2025Keeping 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
This page is also available for…
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|