Originally posted by Robert Milfajt
Originally posted by Scott Folley
####################################################################### Name: ftpBINfileVPN# Purpose: # UPoC type: tps# Args: tps keyedlist containing the following keys:# MODE run mode ("start", "run" or "time")# MSGID message handle# ARGS user-supplied arguments:# ## Returns: tps disposition list:# #proc ftpBINfileVPN { args } { package require TclCurl keylget args MODE mode ;# Fetch mode set dispList {} ;# Nothing to return 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 ARGS.URL url keylget args ARGS.USERPASSWORD userpassword set userdata [ msgmetaget $mh USERDATA ] keylget userdata BINNAME binname keylget userdata FTPOBDIR ftpobdir if { [ catch { keylget userdata SENDPDF } ] } { set sendpdf 1 } else { keylget userdata SENDPDF sendpdf } if { !$sendpdf } { return "{CONTINUE $mh}" } if { [ info exists ftpobdir ] } { set url "$url/../$ftpobdir" } set binname [ file tail $binname ] set ext [ string trimleft [ file extension $binname ] "." ] set lookupExt [ string tolower $ext ] set directory [tbllookup -side input DataFileLocation.tbl $lookupExt] set ch [ curl::init ] $ch configure -verbose 1 $ch configure -upload 1 $ch configure -userpwd $userpassword set outfile $binname set filename $directory$binname puts "ftp://$url/$outfile" $ch configure -url ftp://$url/$outfile $ch configure -infile $filename set retryLimit 3 set retry 0 while { $retry < $retryLimit } { incr retry if { [ catch { $ch perform } status ] } { echo "ftp error:$status" if { $retry == 3 } { return "{ERROR $mh}" } } else { break } } $ch cleanup lappend dispList "CONTINUE $mh" } time { # Timer-based processing # N.B.: there may or may not be a MSGID key in args } shutdown { # Doing some clean-up work } } return $dispList}