BBjInterpreterServer::serverExec

Description

In BBj 4.0 and higher, this method executes a command on the server machine.

Syntax

Return Value

Method

int

serverExec(string commandString)

int

serverExec(BBjVector commandLine)

Parameters

Variable

Description

commandString

Specifies the command line to be executed.

commandLine

In BBj 14.0 and higher, specifies the command and arguments in elements of the BBjVector.

Return Value

Returns the process return code from the operating system.

Remarks

This method is equivalent to invoking SCALL(), except BBj will ignore SETOPTS bit 8, $08$ and always execute the command on the server.

BBj supports two types of server executions: synchronous and asynchronous. In a synchronous server execution, the interpreter waits until the command is completed to resume operation. This is the default operation. In an asynchronous execution, the interpreter does not wait for the command to complete before resuming operation. To invoke a server command asynchronously, insert an ampersand (&) as the last character in the command line.

The BBjVector version of this method prevents the operating system shell from interpreting special characters in the command or arguments. Each argument will be passed verbatim to the command. If an argument contains quotes, these quotes will be passed to the OS-specific call and will not be further processed by BBj.

Example

rem 'Run an application on the server in a thin client environment

rem 'Obtain the instance of the BBjAPI object
let myAPI!=BBjAPI()

rem 'Obtain the instance of the BBjInterpreterServer object
let myIS!=myAPI!.getInterpreterServer()

rem 'Run batch file on the server's machine
let RET=myIS!.serverExec("cmd LogStuff.bat &")

rem 'Run file with spaces asynchronously using a BBjVector
let myVec! = myAPI!.makeVector()
myVec!.addItem("cmd")
myVec!.addItem("C:\Program Files\Batch Programs\LogStuff.bat")
myVec!.addItem("&")

let RET = myIS!.serverExec(myVec!)

See Also

BBjAPI

BBjInterpreterServer

BBjThinClient

BBjThinClient::clientExec

See the BBj Object Diagram for an illustration of the relationship between BBj Objects.