ksc_begin_script / ksc_end_script
The object command structure of PPM Center lends itself nicely to standard, step-by-step processes. In most cases, these commands are fully capable of automating the migration of an object. However, in some circumstances, it is necessary to add additional logic to the commands for an object. For example, perhaps a loop must be generated to repeat a command several times. This is where scripts-on-the-fly are best applied.
Scripts-on-the-fly are designed to leverage the architecture, tools, and knowledge already present in an organization. By using a script-on-the-fly, administrators can define migration logic in their preferred scripting language (such as Bourne Shell, C Shell or Perl). The scripts only need to be defined once. The execution engine copies the script wherever it needs to be executed. The execution engine can also be instructed to clean up the script after it has been executed, leaving no traces behind.
The following syntax is supported:
ksc_begin_script <full_path_to_file_to_be_generated> <directives from any scripting language> ksc_end_script
It is commonly used in the following format:
Since the script will be generated into a temporary directory by use of the
[AS.PKG_TRANSFER_PATH] token, this token will reference a unique temporary directory per execution and end with the proper directory slash ‘/’ or ‘\’. After generation, the script can be transferred to another machine for execution using the
ksc_copy_script commands described in ksc_copy_script special commands.
ksc_begin_script [AS.PKG_TRANSFER_PATH][P.P_SCRIPT_FILENAME] #!/usr/bin/csh # # Script to lock, check in, and re-checkout the original # file using RCS commands. # # Print a warning if the file does not exist. #
if ($#argv != 2) then echo "$0 : wrong number of arguments" echo "Usage: $0 sub_path filename" exit 1 endif
set sub_path = $argv set filename = $argv
if (-e "$sub_path/RCS/$filename,v") then rcs -l $sub_path/$filename ci -m"Before Copy." $sub_path/$filename co -l $sub_path/$filename else echo "Warning: File $sub_path/$filename not found in RCS repository" endif
exit 0 ksc_end_script
# Copy the script to the destination server and excute it. ksc_copy_script_dest_server ksc_connect_dest_server csh [P.P_SCRIPT_FILENAME] rm [P.P_SCRIPT_FILENAME] ksc_exit