To validate the combination of values entered in an installation dialog, you can provide a dialog validation script. The validation script file must be added to a pre-install component. Within a dialog you can validate user data from the complete dialog or from specific input fields.
The dialog verification script is executed when you click Next on the installation dialog. All parameter values entered in the installation dialog are then passed through the shell environment. The script must return zero (0) if the verification has succeeded. In case of an error, the script must return the number of a matching error text in the Resource section of the prototype file. The referred error text number must be in the range of 1 – 255. If a corresponding error text is missing, the text number is displayed in the error message.
The following example checks two entered values, $LOCALE and $DATE. If an English locale is entered, the date field may not contain any date (or in German date representation).
#!/bin/sh
# If one of the parameters $LOCALE or $DATE is not set, # error message 1 is printed [ ! "$LOCALE" -o ! "$DATE" ] && exit 1
# If an English locale has been entered, the date field # must not contain any dot [ "$LOCALE" = "en_US" -a `echo "$DATE" | grep "." 2>/dev/null 1>&2; echo $?` -eq 0 ] && exit 2
# exit without error message exit 0
You can specify validation scripts for text fields (#textfield), installation directories (#instdir), and password fields (#passwordfield). These validation scripts are executed when the user leaves the input field. These scripts are also called, when the Next button is clicked before the dialog verification script is invoked. The entered parameter value is passed to the script as a shell parameter. The script must return zero (0) if the verification has succeeded. In case of an error, the script must return the number of a matching error text in the Resource section of the prototype file. The referred error text number must be in the range of 1 – 255. If a corresponding error text is missing, the text number is displayed in the error message.
The following example checks if a directory name is fully qualified (parameter $INSTDIR):
#!/bin/sh
# If the parameters $INSTDIR is not set, error message 1 is printed [ ! "$INSTDIR" ] && exit 1
# If the parameters $INSTDIR does not start with a slash, # error message 2 is printed [ `expr "$INSTDIR" : '\(.\)'` != "/" ] && exit 2
# exit without error message exit 0
Logging information can be provided by using the parameter PIF_LOG_FILE in the dialog validation scripts, as follows:
if [ $VERBOSE -eq 1 -a -w "$PIF_LOG_FILE" ] then echo "LOG INFORMATION TEXT" >> "$PIF_LOG_FILE" fi
|
Copyright © 2014 CA Technologies.
All rights reserved.
|
|