Originally posted by Todd Wyndham
#!/usr/bin/ksh# Begin Module Header ==============================================================================##------# Name:#------## make_links_for_mda_global_tclprocs.ksh##---------# Purpose:#---------## Create all the $HCIROOT/tclprocs symbolic links for all *.tcl file in the mda_global site.##-------# Notes:#-------## will remove any existing links in the $HCIROOT/tclprocs directory and# will remove $HCIROOT/mda_global/tclprocs/tclIndex if it exists and# will do mktclindex for the $HCIROOT/tclprocs directory##---------# History:#---------## 2000.08.22 Russ Ross# - wrote initial version## 2003.01.08 Russ Ross# - modified to create absolute paths in the links to adhere to team standard## End of Module Header =============================================================================#-------------------------------------------------------------# remove any existing links in the $HCIROOT/tclprocs directory# and chmod -rw-rw-r-- all the mda_global TCL files#-------------------------------------------------------------echo ==========cd $HCIROOT/tclprocschmod 664 *mda_global_link_list=`ls -l | grep ^l | awk '{print $9}'`for mda_global_link in $mda_global_link_list; do echo Deleting link $mda_global_link rm $mda_global_linkdone#----------------------------------------------------------# get list of tcl file that will need links created and# remove $HCIROOT/mda_global/tclprocs/tclIndex if it exists#----------------------------------------------------------cd $HCIROOT/mda_global/tclprocstcl_file_list=`ls *.tcl|sort`rm -f tclIndex#-------------------------------------------# create the symbolic links#-------------------------------------------echo ==========cd $HCIROOT/tclprocsfor tcl_file in $tcl_file_list; do echo creating link for $tcl_file ln -s $HCIROOT/mda_global/tclprocs/$tcl_file $tcl_filedone#--------------------------------------------------# do mktclindex for the $HCIROOT/tclprocs directory#--------------------------------------------------echo ==========echo Making TCL index filemktclindex
Originally posted by Richard Hart
#!/usr/bin/ksh# Begin Module Header ==============================================================================##------# Name:#------## make_links_for_mda_global_tclprocs.ksh##---------# Purpose:#---------## Create all the $HCIROOT/tclprocs symbolic links for all *.tcl file in the mda_global site.##-------# Notes:#-------## will remove any existing links in the $HCIROOT/tclprocs directory and# will remove $HCIROOT/mda_global/tclprocs/tclIndex if it exists and# will do mktclindex for the $HCIROOT/tclprocs directory# will create packages link to directory $HCIROOT/mda_global/tclprocs/packages# will pkg_mkIndex for $HCIROOT/mda_global/tclprocs/packages directory##---------# History:#---------## 2000.08.22 Russ Ross# - wrote initial version## 2003.01.08 Russ Ross# - modified to create absolute paths in the links to adhere to team standard## 2007.04.10 Russ Ross# - modified to create packages link to directory $HCIROOT/mda_global/tclprocs/packages# - modified to only chmod 664 *.tcl files instead of *### 2007.04.19 Russ Ross# - modified to call mkpkgindex.tcl for $HCIROOT/mda_global/tclprocs/packages directory## End of Module Header =============================================================================#-------------------------------------------------------------# remove any existing links in the $HCIROOT/tclprocs directory# and chmod -rw-rw-r-- all the mda_global TCL files#-------------------------------------------------------------echo ==========cd $HCIROOT/tclprocschmod 664 *.tclmda_global_link_list=`ls -l | grep ^l | awk '{print $9}'`for mda_global_link in $mda_global_link_list; do echo Deleting link $mda_global_link rm $mda_global_linkdone#----------------------------------------------------------# get list of tcl file that will need links created and# remove $HCIROOT/mda_global/tclprocs/tclIndex if it exists#----------------------------------------------------------cd $HCIROOT/mda_global/tclprocstcl_file_list=`ls *.tcl|sort`rm -f tclIndex#-------------------------------------------# create the symbolic links#-------------------------------------------echo ==========cd $HCIROOT/tclprocsfor tcl_file in $tcl_file_list; do echo creating link for $tcl_file ln -s $HCIROOT/mda_global/tclprocs/$tcl_file $tcl_filedoneln -sf $HCIROOT/mda_global/tclprocs/packages packages#--------------------------------------------------# do mktclindex for the $HCIROOT/tclprocs directory#--------------------------------------------------echo ==========echo Making TCL index filemktclindex#------------------------------------------------------------------------------# do pkg_mkIndex for the $HCIROOT/tclprocs/packages## if for some reason you choose not to run the standalone script mkpkgindex.tcl# an alternative would be to run the following command# hcitcl -c "pkg_mkIndex -verbose -- $HCIROOT/tclprocs/packages"#------------------------------------------------------------------------------echo ==========echo Making packages index fileecho ""cd $HCIROOT/mda_global/tclprocs/packagesmkpkgindex.tcl -verbose --echo ==========
#!/usr/bin/ksh# this line to escape the next line from the tcl interpreter exec hcitcl "$0" "$@"################################################################################# Name: mkpkgindex# Purpose: Creates a Package Index## Args: -debug# -direct# -verbose# -load pattern# -- # dir <pattern>### Author: Jim Kosloskey# Date-written: 04/12/2007##**************************************************************************************************************#* C O D E A U D I T *#*_____________________________________________________________________________*#*Date I-Catcher Description *#*---------- ---------- -----------------------------------------------*#*04/12/2007 Program inception#*______________________________________________________________________________*#*#*______________________________________________________________________________*#**************************************************************************************************************## Notes:# This procedure is intended to be invoked from a command line# #################################################################################proc mkpkgindex { arg_cnt arg_values } {# Setup Globals global env# Initialize local variables set module "[clock format [clock seconds] -format "%m/%d/%Y %T"] MKPKGINDEX (V1.0):" set return_code 0 set debug 0 set direct 0 set verbose 0 set load 0 set end_o_switches 0 set directory "" set pattern "" set args_ndx 0 set end_o_args_ndx 0 set pattern_ndx 0 set ret_cd 0 set err_lit "" set direct_lit "" set verbose_lit "" set load_lit "" set argopts { {debug f+ debug} {direct f+ direct} {verbose f+ verbose} {load f+ load} {- f+ end_o_switches} }# The pattern for getopts options (as near as I can determine) is as follows:# the first parm (ex {-direct f+ direct} above) is the actual switch value# the second parm can have these values:# 1 - if the switch requires following data # f+ - the switch does not require data# the third parm indicates the variable where the value associated with# the switch will be placed (if there is no value indicated (f+) then # the variable will contain 1 if the switch existed and 0 if it did not.# Get the arguments# The essential command here is the "set args [getopt $argv $argopts]" command.# That command causes the command line to be interrogated and switches indicated by# argopts populated and args will be all command line arguments found which were not# specified in argopts.## The catch is so we can determine if getopt didn't like something. Usage will then# inform the user of the appropriate syntax.# if {[catch {set args [getopt $arg_values $argopts]} err]} { ;# Any errors in the arguments? echo "$module Command line argument error - $err." echo {usage: mkpkgindex.tcl [-direct] [-verbose] [-load pattern] [--] [-dir <pattern...>]where: -debug = Display 'health and well-being' of this proc -direct = Generate an Index with source and load commands. -verbose = Display the name of each file processed and any errors. -load = Dynamically loads packages that match pattern. -- = End of pkg_mkIndex switches (Required) dir <pattern...> = The directory and glob pattern of Package files to be used to make index } }# Construct pkg_mkIndex command from provided switches, etc.# Add the -direct if present if {$direct} { if {$debug} { echo "$module -direct switch detected." } set direct_lit "-direct" }# Add the -verbose if present if {$verbose} { if {$debug} { echo "$module -verbose switch detected." } set verbose_lit "-verbose" }# Add the -load if present if {$load} { if {$debug} { echo "$module -load switch detected." } set load_lit "-load" }# Check to see if the end of switches is present (it MUST be present) if {!$end_o_switches} { puts stderr "$module End of switches switch not located!" puts stderr "$module Aborting and returning non-zero return code." return 001 } lappend mkpkgindex_args "--"# Okay - let's find the directory and pattern# We need to locate the end of switches switch (the directory will be the next list element) if {$debug} { echo "$module Finding Directory argument." echo "$module Locating the end of switches (--)." } set args_ndx [lsearch -exact $arg_values "--"] if {$debug} { echo "$module End of switches found at the >$args_ndx< element of the arguments list." } # Now add one to the index if {$debug} { echo "$module Incrementing to the next element (should be the directory)." } incr args_ndx 1 if {$debug} { echo "$module Now working with element >$args_ndx< >[lindex $arg_values $args_ndx]<." echo "$module Hopefully the above is a directory." } # Now let's get the directory... set directory [lindex $arg_values $args_ndx] if {[string equal "" $directory]} { if {$debug} { echo "$module No directory specified, defaulting to current directory >.<." } set directory "." }# Bump the index by one again (to get by the directory) if {$debug} { echo "$module Incrementing to the next element (should be the start of the file patterns)." } incr args_ndx 1 if {$debug} { echo "$module Now starting with element >$args_ndx<." } # And get the patterns (there can be more than one and we want to get them all)# So we will use the loop command - but - first we need to know the number of # elements in the arguments list. if {$debug} { echo "$module Finding the total number of argument elements..." } set end_o_args_ndx [llength $arg_values] if {$debug} { echo "$module Total number of argument elements is >$end_o_args_ndx<." } # Now let's loop through the patterns# the args_ndx variable points to the start for the loop# and the end_o_args_ndx points to the end for the loop. # The pattern_ndx variable points to the current pattern in the arguments. if {$debug} { echo "$module Looping through the patterns beginning at >$args_ndx - [lindex $arg_values $args_ndx]< until " echo $module >$end_o_args_ndx - [lindex $arg_values $end_o_args_ndx]<." } loop pattern_ndx $args_ndx $end_o_args_ndx { if {$debug} { echo "$module Appending >[lindex $arg_values $pattern_ndx]< to >$pattern<." } lappend $pattern [lindex $arg_values $pattern_ndx] }# Everything is ready - let's issue the command...# First we need to construct the command lappend command "pkg_mkIndex" $direct_lit $load_lit $verbose_lit "--" $directory $pattern# Next we need to remove any nulls. We will use a while command to test if there are any nulls# in the command we just constructed. As long as there are any, we will search (lsearch) for# the location of the first null; then we will delete that element of the list by using lreplace. while {[lcontain $command ""]} { set args_ndx [lsearch -exact $command ""] set command [lreplace $command $args_ndx $args_ndx] } if {$debug} { echo "$module Issuing the pkg_mkIndex command >$command<." } set ret_cd [catch [eval $command] err_lit] if {$ret_cd} { puts stderr "$module Error detected executing pkg_mkIndex >$err_lit<." puts stderr "$module Returning return code 002, aborting!" return 002 } # Normal end if {$debug} { echo "$module pkg_mkIndex successfully executed." } return "0"}mkpkgindex [llength $argv] $argv