TutSystem


Name

TutSystem — execute a shell command

Synopsis

T_INT4 TutSystem(command) 
T_STR command; 

Arguments

command — command to be executed

Return Values

Exit status of command: 0 if successful, non-zero otherwise.

Diagnostics

None

Description

TutSystem passes a command to be executed by an OS command processor. The Bourne shell (/bin/sh) is used on UNIX, DCL is used on OpenVMS, and the Windows command prompt is used on Windows. On MVS, TSO or SAS execution services ultimately processes the request. TutSystem returns the exit status of command (on OpenVMS the exit status 1 is mapped to 0 to emulate UNIX semantics).

TutSystem on UNIX and MVS simply calls the function system. On OpenVMS, TutSystem calls system unless the command string ends with an ampersand (&) character. In this case, TutSystem emulates a UNIX shell by calling LIB$SPAWN with the NOWAIT bit set (on UNIX this is called running the command in the background). On Windows, TutSystem emulates UNIX to accommodate the limitations of COMMAND.COM on Windows. This is useful for writing code that is portable between OpenVMS, UNIX, and Windows.

Caution

If command is run in the background, TutSystem does not return the exit status of command, because doing so would require waiting for command to complete. In this case, TutSystem always returns 0 unless something goes wrong starting command.

If the command is not run in background, TutSystem does not return until the command completes.

See Also

TutCommandParseTypedStr

Examples

This example starts a run-time RTmon in the background:

T_INT4 status; 
status = TutSystem("rtmon -runtime &"); 
if (status != 0) { 
  TutOut("ERROR: could not start rtmon: errors was %d\n", status); 
} 

TIBCO SmartSockets™ Utilities
Software Release 6.8, July 2006
Copyright © TIBCO Software Inc. All rights reserved
www.tibco.com