IBM Tivoli Software IBM Tivoli Software

[ Bottom of Page | Previous Page | Next Page | Contents | Index ]


Utilities

The following methods help you to express functions for tracing activity.

MethodTrace

Syntax
Object.Trace(LogLevel As Integer, Message As String)
Parameters
LogLevel
The log level of the message, 0...3. (3 is the most verbose trace level.)
Message
The Message to Trace.
Description
Writes the Message in the DM for Window Trace if the LogLevel is greater than or equal to the DMW Trace level.
Remarks
Call this method for debugging. To change the trace level from the IBM Tivoli Monitoring server, type the following command: wdmtrceng. For more information, see the IBM Tivoli Monitoring User's Guide.
Error code
S_OK

Method GetInterp

Syntax
Object.GetInterp()As String
Description
Returns the interp of the workstation on which the resource model runs.
Error codes
w32-x86 on Windows NT and Windows 2000 operating systems; aix-r1; hpux10;linux-ix86;linux-s390;solaris2 on UNIX operating systems.

Method Shell

Syntax
Object.Shell(shell As String) As String
Parameters
shell
The command line to launch the new process.
Returns
The first line of the standard output of the launched process that does not start with the # character.
Description
The Shell method runs a new program on the monitored host and retrieves its output.
Remarks
It is possible to launch customized scripts that are available on the endpoint by issuing, for example,
perl myperl.pl
The launched process must return within 60 seconds, otherwise an error generates.
Error codes

TMWSERVICE_E_NO_INTERP_SUPPORT
TMWSERVICE_E_NO_DATA
TMWSERVICE_E_IMPLIED_ERROR
TMWSERVICE_E_ERRORVALUE_SCRIPT_ERROR S_OK

Method GetShellStdOut

Syntax
Object.GetShellStdOut() As String
Returns
The standard output of the process spawned by the last call to the "Shell" method.
Description
The GetShellStdOut method is used to get the full standard output of a spawned process. If the standard output is empty, this method returns an empty string.
Remarks
The Shell method returns only the first line of the standard output that does not start with the # character, while this method returns the full standard output.
Error codes
S_OK

Method GetShellStdErr

Syntax
Object.GetShellStdErr() As String
Returns
The standard error of the process spawned by the last call to the "Shell" method.
Description
The GetShellStdOut method gets the full standard error of a spawned process. If the standard error is empty, this method returns an empty string.
Error codes
S_OK

Method GetShellRetCode

Syntax
Object.GetShellRetCode() As Integer
Returns
The exit code of the process spawned by the last call to the "Shell" method.
Description
The GetShellRetCode method gets the exit code of a process. If the process succeeds, the exit code is usually zero.
Error codes
S_OK

Example

Table 18. Basic Object Method utility examples
Visual Basic example:

Dim interp As String
interp = Svc.GetInterp()
Svc.Trace(3, "interp: " + interp)

Dim out As String
out = Svc.Shell("perl myScript.pl")
Svc.Trace(3, "first line of output: " + out)

out = Svc.GetShellStdOut()
Svc.Trace(3, "std output: " + out)

out = Svc.GetShellStdErr()
Svc.Trace(3, "std err: " + out)

Dim retCode As Integer
retCode = Svc.GetShellRetCode()
Svc.Trace(3, "return code: " + retCode)

JavaScript example:

var interp;
interp = Svc.GetInterp();
Svc.Trace(3, "interp: " + interp);

var out;
out = Svc.Shell("perl myScript.pl");
Svc.Trace(3, "first line of output: " + out);

out = Svc.GetShellStdOut();
Svc.Trace(3, "std output: " + out);

out = Svc.GetShellStdErr();
Svc.Trace(3, "std err: " + out);

var retCode;
retCode = Svc.GetShellRetCode();
Svc.Trace(3, "return code: " + retCode);


[ Top of Page | Previous Page | Next Page | Contents | Index ]