4.1.18. Script Node

Your Ad Here

The Script Node embeds a script that you want to have executed. This can be a shell script that you use to wrap an external application, or a script in one of the supported scripting languages. Data, both files and values, can be passed to, and extracted from, the script.

Node Configuration

The Script Node Properties Dialog

Figure 4.41. The Script Node Properties Dialog

To configure a Script node you need to provide the following parameters:

Finally, you need to actually type in the script. To do this you need to click on the Edit Script button to open the Script Editor.

If everything works correctly, the application exit value will be the one returned by the script upon exit. However, if something goes wrong, one of the following reserved exit values could be returned:

910A failure occurred while retrieving the output data
912The job has been killed before it could terminate
920The job was set-up incorrectly, and it was not possible to start it
921The output files and data could not be retrieved

Additional exit values can be returned depending on the script language used. For UNIX Shell and DOS Batch Shell, possible exit codes are:

1001It was not possible to retrieve the current environment
1002The external process failed unexpectedly

A Jython Script can instead return one of the following exit values:

2001The Jython interpreter was not found
2002It was not possible to assign a design variable value to a Jython variable
2003The script could not be found
2004It was not possible to assign to the CWD variable the full path of the script working directory
2005The script failed to run (consult ErrLog for additional information on the cause)
2006It was not possible to extract one or more variables from the Jython environment

A Bean Shell Script can return one of the following exit values:

3001The Bean Shell interpreter was not found
3002It was not possible to assign a design variable value to a Bean Shell variable
3003The script could not be found
3004It was not possible to assign to the CWD variable the full path of the script working directory
3005The script failed to run (consult ErrLog for additional information on the cause)
3006It was not possible to extract one or more variables from the Bean Shell environment

A VBScript can return one of the following exit values:

4001The script could not be found
4002The wrapping script could not be written to disk

A JScript can return one of the following exit values:

5001The script could not be found
5002The wrapping script could not be written to disk

Input Connections

The Script node input can be connected to one or more nodes. The connectable nodes are different for each connector. The process input connector can only be connected to the process output connector of nodes that belong to one of the following types:

For each node belonging to one of the first seven node types (i.e., for each application node) that you connect, you must also indicate for which values of the application exit value you want the Process Flow to be routed through this script node (see Section 4.2.7, "Conditional Expression Legal Syntax"). Only when the application exit value matches the condition this script will be executed.

The data input connector can be connected only to nodes that belong to one of the following types:

For each node belonging to one of the last five node types (i.e., for each variable) that you connect, you must also indicate the name of the script environment variable to which you want to assign the value.

Output Connections

The Script node output can be connected to one or more nodes, different for each connector. The process output connector can only be connected to the process input connector of nodes that belong to one of the following types:

For each connected node, you must also indicate for which values of the application exit value you want the Process Flow to be routed through the connected node (see Section 4.2.7, "Conditional Expression Legal Syntax"). Only the output branch for which the exit value matches the corresponding condition will be transversed. If no condition matches the exit value, it is assumed that the design is failed, and the Work Flow execution is interrupted.

Note

The conditions must be mutually exclusive (i.e., there can be no exit value for which two or more conditions hold true).

The data output connector can be connected only to nodes that belong to one of the following types:

For each output file, you also need to specify for which values of the exit value you want the file to be processed (see Section 4.2.7, "Conditional Expression Legal Syntax"). Only those output branches for which the exit value matches the corresponding condition will be transversed.

For each output variable and buffer variable node connected, you must also indicate the name of the script environment variable from which you want to extract the value.

Logic Log Messages

The following error messages can be associated with an script node:

102INVALID EXIT CONDITION(S)The conditions for the output nodes that support the Process Flow routing are not mutually exclusive
103MISSING SCRIPT FILENo script has been defined
126SCRIPT NODE NOT REACHEABLEThe Process Flow cannot be routed through the script node because an appropriate input connection is missing
127NO EXIT PATH FOR SCRIPT NODEThe Process Flow cannot be routed past the script node because an appropriate output connection is missing
134MISSING NAME FOR I/O VARIABLEA name has not been assigned to one or more variables passed to, or extracted from, the script

4.1.18.1. Script Editor

The Script Editor allows you to type a script to be executed. The script is responsible for correctly using the input variables and files, and for producing the required variables and files. Also, the script must exit with an exit value that is descriptive of any problem encountered (this is the value that will be used inside modeFRONTIER to determine whether output variables should be extracted from output files, transfer files should be transferred, and how the process should be routed).

Caution

For script languages other than UNIX Shell and DOS Batch Shell, the exit value must be passed back to modeFRONTIER by assigning a value to the EXIT_VALUE variable before the end of the script. If such variable is not set, the exit value is assumed to be zero. For UNIX Shell scripts the exit command must be used, whereas for DOS Batch Shell scripts the ERRORLEVEL environment variable must be set.

If a shell script is used to wrap an external application, the script must perform all the operations necessary to correctly set up the application, and must feed it the necessary input file(s) (set up within modeFRONTIER by connecting Input File nodes to the Script node).

Script environment set-up

Before executing the script, a working directory is set up for it, and all the input, support, and transfer files required (specified within modeFRONTIER by connecting Input File, Support File, and Transfer File nodes to the Script node) are copied in that directory.

If a UNIX Shell or a DOS Batch Shell is used, the script will be executed in the working directory for the script. Also, the system environment under which the script will be executed will be identical to the environment under which the Launcher has been started. In addition, the value of each variable provided as an input to the Script node will be assigned to an environment variable, having the name specified in the Script properties dialog. Furthermore, some environment variables that are design-specific will also be set. These include:

  • APPL_NAME: the full path name for the script being executed

  • APPL_OUT_ENV: the name of the file where the environment must be saved before exiting the script (see below).

  • APPL_PWD: the absolute path of the working directory for the script

  • DESIGN_ID: the ID for the design being evaluated

  • PROJECT_NAME: The name of the modeFRONTIER project within which the script is being run

  • APPL_STDOUT: The name for the file where the standard output will be redirected

  • APPL_STDERR: The name for the file where the standard error will be redirected

  • APPL_PRIORITY: The priority with which the script will be executed

  • ESTECO_USER: The username of the user that requested the execution. This is not necessarily the user that owns the script, because, for example, the script could be run by the Launcher on behalf of a remote user.

Warning

The environment variable names has been carefully choosen to prevent accidental shadow of user defined variables. User must take on the responsability to avoid variable name collisions.

When any other scripting language is used, the full path of the working directory for the script will be assigned to a variable in the script workspace named CWD (Current Working Directory). The script will need to use this variable to locate any input file it might need, or to create files to be used by subsequent nodes. Also, the value of each variable provided as an input to the Script node will be assigned to a variable in the script workspace, using the name specified in the Script properties dialog. Furthermore, the variables DESIGN_ID, PROJECT_NAME and ESTECO_USER will also be assigned the same values described above for a shell script.

Data retrieval

After the script has been executed, the exit value, and possibly the value of some output variables, must be retrieved. For UNIX Shell scripts the exit value is the one passed to the exit command. For DOS Batch Shell scripts the exit value is equal to the ERRORLEVEL environment variable. When any other scripting language is used, the value of the EXIT_VALUE variable is used. If such variable is not set, the exit value is assumed to be zero.

The values for output and buffer variables connected as outputs to the Script node are extracted from workspace variables (shell enviroment variables for Shell Scripts) having the names specified in the Script properties dialog.

Caution

For UNIX Shell and DOS Batch Shell scripts, the environment is cleaned upon script termination. Thus, to enable modeFRONTIER to retrieve the environment variables set within the script, the user MUST save the content of the environment into the file indicated in the environment variable APPL_OUT_ENV before exiting the script (i.e., the shell command

    env > ${APPL_OUT_ENV} [UNIX Shell]
      
or
    set > %APPL_OUT_ENV% [DOS Batch Shell]
      
should precede any exit command).

Script Editor Features

The Script Editor

Figure 4.42. The Script Editor

The Script Editor is a simple text editor, and, through the menu and the toolbar at the top of the dialog, it allows you to perform the classic editing operations. More precisely, the File menu allows you to carry out the following operations:

  • File->New (Ctrl-N): Clears the current content of the script editor, and lets you start over.

  • File->Open (Ctrl-O): Loads a file from the file system into the script editor.

  • Edit->Save (Ctrl-S): Saves the current content of the script editor into an external file.

The Edit menu instead enables you to do the following:

  • Edit->Cut (Ctrl-X): Removes the text currently selected, putting it on the system clipboard.

  • Edit->Copy (Ctrl-C): Copies into the system clipboard the text currently selected.

  • Edit->Paste (Ctrl-V): Copies into the text, after the current location of the cursor, the current content of the system clipboard.

  • Edit->Find (Ctrl-F): Locates a string within the text.

  • Edit->Find Next (F3): Repeats the search for the last string used in a find command.

  • Edit->Go To Line (Ctrl-G): Jumps to a specific line number within the text.

  • Edit->Undo (Ctrl-Z): Cancels the last operation performed.

  • Edit->Redo (Ctrl-Y): Re-applies the last operation that was undone.

Some of these operations can also be invoked using the buttons in the toolbar.

Toolbar

Figure 4.43. Toolbar

In the toolbar there is also an encoding selector, which allows you to change the encoding to be used to save the script. This can become useful if you introduce in the script characters that are not supported by the original encoding (e.g., accented letters or Far East characters). Of course, you must be sure that the scripting engine will be able to automatically recognize such encoding.

In addition, you can specify the convention to be used to terminate each line in the script. Here you can select either the DOS format, or the UNIX format. In the former case, each line is terminated by a CR - LF pair (carriage return - line feed); if the UNIX format is select, only a LF is indicate a line termination. Specifying the correct line termination is especially important for DOS operation, because UNIX-terminated text files could be interpreted incorrectly.


Return to modeFRONTIER Index


Your Ad Here
??