|Powered by QM on a Linux server|
KnowledgeBase 00054: Executing Code on a Remote Server
It is sometimes useful for an application on one system to be able to execute a subroutine or a command on another system. The QMBasic interface to the QMClient API makes this easy.
Using QMClient inside a QMBasic Program
There is a class module in the global catalogue named !QMCLIENT that provides the ability for an application to open a connection to a remote QM server, subject to the usual QMClient security rules.
SESSION = OBJECT("!QMCLIENT") IF SESSION->CONNECT(servername, port, username, password, account) THEN ...processing... SESSION->DISCONNECT END
Executing a Subroutine
To execute a subroutine on the remote system, the processing element of the above code fragment becomes
SESSION->CALL("subrname", arg1, arg2,...)Data can be passed in both directions via the arguments in the same way as for other subroutine calls.
Executing a Command
To execute a command on the remote system, the processing element of the above code fragment becomes
RESPONSE = SESSION->EXECUTE(command, state)where the returned value is the output from the command and the state variable indicates the status of the executed command. In particular, this allows the program initiating the command to handle requests for input (see the QM Reference Manual for details).