Originally posted by Bill May
Originally posted by Sundeep Kumar
Originally posted by Greg Eriksen
####################################################################### Name: tps_local_archive# Purpose: used as fileset ibdel proc to archive rather than# delete processed file.# UPoC type: tps# Args: tps keyedlist containing the following keys:# MODE run mode ("start", "run" or "test")# MSGID message handle# ARGS user-supplied arguments:# ## Returns: tps disposition list:# Returns "KILL" so thread does not try to delete file which# no longer exists because it has been renamed and moved.#proc tps_local_archive { args } { keylget args MODE mode set proc_name [lindex [info level [info level]] 0] switch -exact -- $mode { start { # Perform special init functions # N.B.: there may or may not be a MSGID key in args } run { # 'run' mode always has a MSGID; fetch and process it keylget args MSGID mh keylget args CONTEXT ctx # Check for correct context if {![cequal $ctx "fileset_ibdel"]} { echo "ERROR proc used in wrong context" echo "Context should be fileset_ibdel" echo "Proc called in: $ctx" return "{KILL $mh}" } # As far as I can tell from testing, whereas the ibdirparse proc # message contains a list of file name(s), this ibdel proc gets passed # just one file name per call and it includes the full file path. So, # while I extract the "first" element from the "list", I don't believe # it's strictly necessary. set msgList [msgget $mh] set filePath [lindex $msgList 0] # Collect or create the file names and paths for archiving. set fileDir [file dirname $filePath] set fileName [file tail $filePath] set timestamp [clock format [clock seconds] -format %Y%m%d%H%M%S] set archiveName ${fileName}.$timestamp set archiveDir [file join $fileDir archive] set archivePath [file join $archiveDir $archiveName] set emails "INTEGRATION@yourdomain.org" # Create the archive subdirectory if it doesn't already exist. if {![file exists $archiveDir]} { echo "creating archive directory" if {[catch {file mkdir $archiveDir} err]} { echo "***n*** $proc_name - Error creating archive directoryn***" echo $err set subject "_ERROR_ - Archive $fileDir" set message "nError creating archive directory in $fileDir" if {[catch {your_email_proc "$emails" "$subject" "$message" "your_email_server" "your_domain.org" "" ""} err]} { echo "error sending email" echo $err } } } # Rename file while moving to archive subdirectory. if {[catch {file rename $filePath $archivePath} err]} { echo "***n*** $proc_name - Error moving and renaming file:n*** $filePath to $archivePath n***" echo $err set subject "_ERROR_ - Archive $fileName" set message "nError renaming file $filePath to $archivePath" if {[catch {your_email_proc "$emails" "$subject" "$message" "your_email_server" "your_domain.org" "" ""} err]} { echo "error sending email" echo $err } } else { echo "***n*** $proc_name - archived file: $archivePath n***" } # Attempt to gzip or compress the archived file. if {[catch {exec gzip $archivePath} err]} { echo "***n*** $proc_name - Error gzipping file $archivePath n***" echo $err if {[catch {exec compress "$archivePath"} err]} { echo "***n*** $proc_name - Error compressing $archivePath n***" echo $err } } return "{KILL $mh}" } time { # Timer-based processing # N.B.: there may or may not be a MSGID key in args } shutdown { echo "*** $proc_name shutting down." } default { error "Unknown mode '$mode' in $proc_name" } }}
######################################################################## Name: ibdel_cp_to_ibsave## Purpose: Save a copy of the file(s) to Inboundsave before the # engine deletes it## Creator: Kevan Riley## On: 2009.09.01## UPoC type: fileset_ibdel## Args: tps keyedlist containing the following keys:# {MODE run}# {MSGID message0} # {CONTEXT fileset_ibdel}# {ARGS {}}# {VERSION 3.0}## Returns: CONTINUE - where the "message" is the list# of file names for the engine to delete.########################################################################proc ibdel_cp_to_ibsave { args } { global env HciConnName HciSiteDir set procName "[lindex [info level 1] 0]" set Process "[lindex [split [pwd] /] end]" set module "$HciConnName/$procName" set conn "$HciConnName" set context [keylget args CONTEXT] set mode [keylget args MODE] catch {keylget args MSGID mh} set dispList {} ;# Nothing to return echo ######################################### echo "[clock format [clock seconds] -format "%Y-%m-%d %H:%M:%S"]" echo PROC: $procName echo CONTEXT: $context MODE: $mode catch {echo [set filelist [msgget $mh]]} echo ######################################### switch -exact -- $mode { start { # Perform special init functions } run { set ibSaveDir [file join $env(HCISITEDIR) exec processes] set ibSaveDir [file join $ibSaveDir $Process InboundSave] # # make sure "ibSaveDir exists, if not create it # if {![file exists $ibSaveDir]} { echo " creating InboundSave directory...." if {[catch {file mkdir $ibSaveDir} result]} { puts "ERROR: $module - $context - Unable to create "$ibSaveDir"" puts " result was: $result" } ;#end if } ;#end if # # there really should only be one file here, but we'll treat it as a # list just in case # foreach file $filelist { set filename $file set newFile "[file tail $file]" append newFile "_" append newFile [clock format [clock seconds] -format "%Y%m%d_%H%M"] set newFile [file join $ibSaveDir $newFile] echo "INFO: Archiving file to $newFile.gz" if {[catch {file copy $filename $newFile} result]} { echo "ERROR: file rename $filename $newFile failed with: $result" } ;#end if set cmd "exec gzip $newFile &" if {[catch $cmd result]} { echo "ERROR: gzip failed with: $result" } ;#end if set dttm "[clock format [clock seconds] -format "%Y-%m-%d %H:%M:%S"]" echo "INFO: $module - Done - $dttm" } ;#end foreach file lappend dispList "CONTINUE $mh" } time { # Timer-based processing } shutdown { # Doing some clean-up work } } ;#end switch mode return $dispList} ;# end proc dirdelete_nchess
Originally posted by Jennifer Hardesty
Originally posted by Dianna Braden