PCL and Customization > System and Utility Functions > Spawning a Process
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX''">XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX''">   
Spawning a Process
Application developers may have the need to execute other programs in order to perform certain operations. Programs that execute other programs are said to be “spawning a process.” The following sections provide details for spawning a process from inside Patran, how a database can be locked to prevent access during the spawning process, and how to add entries to the Status Database in order track the status of a spawned process.
Spawning a remote process is one method of performing customized functionality. The PCL function utl_process_spawn is used by Patran to spawn a process. See The PATRAN Command Language (PCL) Introduction (Ch. 2) for a summary of the related PCL functions.
Example: An application developer has an executable (script or program) called mytranslator that requires the database name and a count. The developer’s executable, mytranslator, should reside somewhere along the PCL path, as defined by the PCL directive, !!PATH in either the p3prolog.pcl file or the p3epilog.pcl file. See The p3prolog.pcl and p3epilog.pcl Files (p. 54) in the Patran Reference Manual.
FUNCTION start_mytrans(dbname, count)
string dbname[]
integer count
integer status
string mytrans[256], cmd[512]
 
/* Find where mytranslator is - we should check for errors */
status = file_get_filespec(“mytranslator,” ”OP,” mytrans)
 
/* Format the argument string required by mytranslator */
str_formatc(cmd,”%s -db %s -cnt %d,” mytrans, dbname, count)
 
/* Spawn the process and continue; do not wait for completion. */
/* If a process spawning error occurs, display it as severity 2 (WARNING) */
status = utl_process_spawn(cmd, FALSE)
IF ( utl_process_error( status ) ) THEN
		utl_display_error( status, 2)
ENDIF
END FUNCTION /* start_mytrans */
The PCL call:
start_mytrans(“my.db,”542)
will invoke the following from the bourne shell:
mytranslator -db my.db -cnt 542
 
Note:  
For portability reasons, all scripts should be written for the bourne shell.