Open System Services Porting Guide (G06.29+, H06.06+, J06.03+)

Starting an OSS Program From the Guardian Environment
Migration from the Guardian environment to the OSS environment can involve the ability to start
an OSS program from the Guardian environment, which you can do either using commands or
programmatically, as described in the following subsections:
“Using OSH From TACL” (page 152)
“Using system() in a Guardian Program” (page 152)
“Using PROCESS_SPAWN_ in a Guardian Program” (page 152)
“Using the Guardian LISTNER Program” (page 154)
Using OSH From TACL
The OSH command can be used to run a process in the OSS environment from the Guardian
environment. The OSH command is a Guardian program that spawns an OSS process within the
same node, allowing you to specify the environment and initial process attributes of the child
process. Using the -c option, you can submit a command to the OSS child process, as follows:
osh -c command_string
where the command string can be any valid OSS shell command, OSS utility name, or script file
pathname. Parameters to be processed by the named command, utility, or script can also be
included. Standard I/O streams can be redirected from or to OSS files. Input and output can be
redirected to Guardian processes and EDIT files by using the OSSTTY facility. (OSSTTY can be
invoked on the OSH command line. See the Open System Services Programmer’s Guide for more
information about OSSTTY). A specific OSS program can be run by using the -p option, for
example:
osh -p pathname arg1 arg2 ... argn
In this case, the specified program is run as a child process from the TACL prompt. By default, the
OSH command without arguments creates a child process running the login shell. The Guardian
DEFINEs are inherited by OSH and resulting child processes. All Guardian PARAMs are converted
into OSS environment variables for the child process. More details on starting up an OSS program
using the OSH command from TACL are available in the osh(1) reference page either online or
in the Open System Services Shell and Utilities Reference Manual.
Using system() in a Guardian Program
OSS programs can be started from the Guardian environment in a programmatic way by using
the system() Guardian C run-time routine to run the OSH command, which in turn can run an
OSS command. When the OSH command is run programmatically, the TACL RUN options IN and
OUT must be specified. More details on starting up an OSS program using the system() function
is available in the system(3) reference page either online or in the Open System Services Library
Calls Reference Manual.
Example 1 provides sample code: the command string passed to the Guardian program can be
any valid OSS shell command.
The OSS command line must be given to the Guardian RUNOSSP command within double quotes
(" ") to make sure there is no interpretation of special characters within the command string. An
example follows:
run runossp "ls -l /home/stu01 > listfile"
Here the output file listfile is produced in the OSS file system. An OSS script can also be run
using the RUNOSSP utility from the TACL command interpreter.
Using PROCESS_SPAWN_ in a Guardian Program
Another way to start OSS programs from the Guardian environment is to use the
PROCESS_SPAWN_ procedure call in a Guardian program from the TACL command interpreter.
152 Migrating Guardian Applications to the OSS Environment