Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
;################################################################
;# TN_SWAP Procomm Script #
;# Author: Chris Jackson. #
;# Disclaimer: The script is provided without any warranty #
;# as to it's accuracy, reliability or suitability. #
;# #
;# This script will swap the programming between two TNs on #
;# NORTEL Meridian PABXs. It does this in the following manner. #
;# #
;# ASK USER for 1st TN #
;# CHECK 1st TN for INVALID CHARACTERS #
;# ASK USER for 2nd TN #
;# CHECK 2nd TN for INVALID CHARACTERS #
;# ASK USER FOR CONFIRMATION TO RUN SCRIPT #
;# CHECK TNs are VALID #
;# call to FINDTYPE procedure (to find TYPE) #
;# CHECK TYPES Match for TNs given #
;# CHECK SPARE TNs exist for TYPE #
;# GET ORIGINAL DNs by TNB|Screen capture|read from file #
;# and ACD DETECTION ! Script will abort if ACDs #
;# CHECK SPARE DNs exist #
;# #
;# Moves and Changes START #
;# COPY From 1st TN -> 1st Spare using 1st Spare DN #
;# COPY From 2nd TN -> 2nd Spare using 2nd Spare DN #
;# OUT 1st Orig TN #
;# OUT 2nd Orig TN #
;# COPY From 1st Spare TN -> 2nd Orig TN using 1st Orig DN #
;# COPY From 2nd Spare TN -> 1st Orig TN using 2nd Orig DN #
;# OUT 1st SPARE TN #
;# OUT 2nd SPARE TN #
;# #
;# FINDTYPE Procedure - Finds TYPE #
;# TERM Procedure - Runs before Exiting, Incl's Error Messages. #
;# #
;################################################################
integer Len
integer Choice = 0 ;user verification integer
integer verifile = 0 ;file contents verification integer
integer cnt_DN = 0 ;increment integer for DNs
integer DN_Len = 0 ;3 or 4 Digit DN Length integer
integer SpareDNs = 0 ;Spare DNs Integer
integer MACStart = 0 ;Moves & Changes detection integer
string AAATNSwap, BBBTNSwap, Temp_Str, Swap_Str, XXXTNSwap, LineInfo, Temp_End
string AAAType, BBBType, Str_Temp, AAA_LUVU, BBB_LUVU, ASpareTN, BSpareTN, ASpareDN, BSpareDN, AOrigDN, BOrigDN
string FNameCap = "deleteme.txt"
string F_Erra = "C:\Program Files\Symantec\Procomm Plus\Capture\Error.txt"
proc main
WHEN USEREXIT call TERM
;logout of any active LDs
transmit "****^M"
waitfor ">" 2
;ASK USER for 1st TN
sdlginput "TN SWAP" "Please Enter the 1st TN..." AAATNSwap 11 DEFAULT
IF FAILURE
call term
ENDIF
;CHECK 1st TN for INVALID CHARACTERS
IF strcspn AAATNSwap "0123456789"
;contains numbers
IF strcspn AAATNSwap "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~!@#$%^&*()_+-={}|[]\:";'<>?,./"
usermsg "1st TN Input INVALID CHARACTERS - %s" AAATNSwap
call term
ENDIF
ELSE
usermsg "1st TN Input INVALID CHARACTERS - %s" AAATNSwap
call term
ENDIF
;ASK USER for 2nd TN
sdlginput "TN SWAP" "Please Enter the 2nd TN..." BBBTNSwap 11 DEFAULT
IF FAILURE
call term
ENDIF
;CHECK 2nd TN for INVALID CHARACTERS
IF strcspn BBBTNSwap "0123456789"
;contains numbers
IF strcspn BBBTNSwap "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~!@#$%^&*()_+-={}|[]\:";'<>?,./"
usermsg "2nd TN Input INVALID CHARACTERS - %s" BBBTNSwap
call term
ENDIF
ELSE
usermsg "2nd TN Input INVALID CHARACTERS - %s" BBBTNSwap
ENDIF
transmit "LD 20^M"
waitfor "REQ:" 2
;USER CONFIRMATION
Temp_Str = "Swap programming between TN's "
strcat Temp_Str AAATNSwap
strcat Temp_Str " & "
strcat Temp_Str BBBTNSwap
strcat Temp_Str "?"
while Choice <= 5 ; Loop while user doesn't choose.
sdlgmsgbox " ### WARNING ! ###" Temp_Str QUESTION YESNO Choice 2
yield
endwhile
if Choice == 7 ; See if user said no.
call term
endif
;CHECK TNs are VALID
STATMSG "Checking TNs are VALID..."
XXXTNSwap = AAATNSwap
call findtype
AAAType = Temp_Str ;TYPE as found in called procedure
XXXTNSwap = BBBTNSwap
AAA_LUVU = Str_Temp ;Loop info to check for unused units
call findtype
BBBType = Temp_Str ;TYPE as found in called procedure
BBB_LUVU = Str_Temp ;Alternate Loop to check for unused units
;CHECK TN TYPES Match
STATMSG "Checking TN TYPEs MATCH..."
if NOT strcmp AAAType BBBType
Temp_Str = "TN TYPE's DO NOT MATCH. "
strcat Temp_Str AAAType
strcat Temp_Str " | "
strcat Temp_Str BBBType
ERRORMSG "%s" Temp_Str
call term
endif
;CHECK SPARE TNs exist for Type (LUVU) (LD 20)
STATMSG "Checking SPARE TNs exist..."
mspause 250
FNameCap = "deleteme.txt"
;capture screen display to file
set capture file FNameCap ; Set name of capture file.
set capture overwrite ON
capture on ; Open up the capture file.
transmit "LUVU^M"
waitfor "TYPE:" FOREVER
Temp_Str = AAAType
transmit Temp_Str
waitfor "TN" FOREVER
Temp_Str = AAA_LUVU
strcat Temp_Str "^M"
transmit Temp_Str
waitfor "CDEN" FOREVER
transmit "^M"
;repeat for Loop from 2nd TN
waitfor "REQ:" FOREVER
transmit "LUVU^M"
waitfor "TYPE:" FOREVER
Temp_Str = BBBType
transmit Temp_Str
waitfor "TN" FOREVER
Temp_Str = BBB_LUVU
strcat Temp_Str "^M"
transmit Temp_Str
waitfor "CDEN" FOREVER
transmit "^M"
waitfor "REQ:" FOREVER
capture off ; Close the capture file.
mspause 250
;playback from capture file
FNameCap = "C:\Program Files\Symantec\Procomm Plus\Capture\deleteme.txt"
if isfile FNameCap ; Make sure file exists.
if fopen 0 FNameCap READ ; Open file for read.
while not feof 0 ; Loop to end of file.
fgets 0 LineInfo ; Get line from file.
if rstrcmp LineInfo "REQ: LUVU" 9 ;1st 9 chars match
verifile = 1 ;verification of file contents
endif
if rstrcmp LineInfo "TYPE " 5 ;1st 5 chars match
;order of below scripts intentional to obtain TNs from different lines
if verifile == 2 ;verification of file contents & that we have 1 TN already
substr BSpareTN LineInfo 14 11 ;extract TN info
verifile ++
endif
if verifile == 1 ;verification of file contents
substr ASpareTN LineInfo 14 11 ;extract TN info
verifile ++
endif
endif
endwhile
endif
endif
fclose 0
if verifile != 3 ;we DON'T have both Spare TN Info's
USERMSG "Unable to obtain 2 Spare TN's."
call term
endif
;GET ORIGINAL DNs by TNB|Screen capture|read from file/ACD DETECTION!
STATMSG "Obtaining Original DNs..."
mspause 250
FNameCap = "deleteme.txt"
;capture screen display to file
set capture file FNameCap ; Set name of capture file.
set capture overwrite ON
capture on ; Open up the capture file.
transmit "PRT^M"
waitfor "TYPE:" FOREVER
transmit "TNB^M"
waitfor "TN" FOREVER
transmit AAATNswap
mspause 300
transmit "^M"
waitfor "DATE" FOREVER
transmit "^M"
waitfor "PAGE" FOREVER
transmit "^M"
waitfor "DES" FOREVER
transmit "^M"
waitquiet 2 FOREVER
transmit "^M"
;repeat for 2nd TN
transmit "PRT^M"
waitfor "TYPE:" FOREVER
transmit "TNB^M"
waitfor "TN" FOREVER
transmit BBBTNswap
mspause 300
transmit "^M"
waitfor "DATE" FOREVER
transmit "^M"
waitfor "PAGE" FOREVER
transmit "^M"
waitfor "DES" FOREVER
transmit "^M"
waitquiet 2 FOREVER
transmit "^M"
capture off ; Close the capture file.
mspause 250
;playback from capture file
FNameCap = "C:\Program Files\Symantec\Procomm Plus\Capture\deleteme.txt"
if isfile FNameCap ; Make sure file exists.
if fopen 0 FNameCap READ ; Open file for read.
while not feof 0 ; Loop to end of file.
fgets 0 LineInfo ; Get line from file.
if cnt_DN == 1 ;we have 1st DN / obtain 2nd DN
;this needs to appear above cnt_DN = 0
if rstrcmp LineInfo "DN " 5 ;1st 5 chars match
substr BOrigDN LineInfo 5 4
cnt_DN ++
endif
if rstrcmp LineInfo "KEY 00 SC" 9 ;1st 9 chars match
substr BOrigDN LineInfo 12 4
cnt_DN ++
endif
endif
if cnt_DN == 0 ;we have no DN info yet
if rstrcmp LineInfo "DN " 5 ;1st 5 chars match
substr AOrigDN LineInfo 5 4
cnt_DN ++
endif
if rstrcmp LineInfo "KEY 00 SC" 9 ;1st 9 chars match
substr AOrigDN LineInfo 12 4
cnt_DN ++
endif
endif
;### Detect if TYPE = ACD ###
if rstrcmp LineInfo "KEY 00 ACD" 11 ;1st 11 chars match
fclose 0 ;close file
USERMSG "Nortel Networks does not support the use of CPY command on ACD agents. Script will abort."
call term ;exit
endif
;### end of ACD detection ###
;determine if Orig DNs are 3 or 4 Digit.
IF strchr AOrigDN ' ' ;DN info contains a SPACE
DN_Len = 3
ELSE
DN_Len = 4
ENDIF
IF strchr BOrigDN ' ' ;DN info contains a SPACE
DN_Len = 3
ELSE
DN_Len = 4
ENDIF
endwhile
endif
endif
fclose 0
;CHECK SPARE DNs exist
STATMSG "Checking SPARE DNs exist..."
mspause 250
FNameCap = "deleteme.txt"
;capture screen display to file
set capture file FNameCap ; Set name of capture file.
set capture overwrite ON
capture on ; Open up the capture file.
transmit "PRT^M"
waitfor "TYPE:" FOREVER
transmit "LUDN^M"
waitfor "CUST" FOREVER
transmit "^M"
waitfor "DN" FOREVER
;obtain 1st Digit of 1st OrigDN
substr Temp_Str AOrigDN 0 1
strcat Temp_Str "^M"
transmit Temp_Str
waitquiet 2
;repeat for 2nd Orig DN
transmit "PRT^M"
waitfor "TYPE:" FOREVER
transmit "LUDN^M"
waitfor "CUST" FOREVER
transmit "^M"
waitfor "DN" FOREVER
;obtain 1st Digit of 2nd OrigDN
substr Swap_Str BOrigDN 0 1
strcat Swap_Str "^M"
transmit Swap_Str
waitquiet 2
capture off
pause 2
;playback from capture file
FNameCap = "C:\Program Files\Symantec\Procomm Plus\Capture\deleteme.txt"
if isfile FNameCap ; Make sure file exists.
if fopen 0 FNameCap READ ; Open file for read.
while not feof 0 ; Loop to end of file.
fgets 0 LineInfo ; Get line from file.
IF SpareDNs == 1 ;this script needs to appear before SpareDNs value is set to 1
if rstrcmp LineInfo Temp_Str 1 ;1st char matches
strextract ASpareDn LineInfo " " 0 ;Extract 1st Spare DN from 1st Col Pos
endif
if rstrcmp LineInfo Swap_Str 1 ;1st char matches
strextract BSpareDn LineInfo " " 1 ;Extract 2nd Spare DN from 2nd Col Pos
endif
SpareDNs = 2
ENDIF
IF SpareDNs == 0 ;required to ensure trigger once only
IF strfind LineInfo "CUSTOMER 00 - UNUSED DNS:" ;Capture file verified
SpareDNs = 1
ENDIF
ENDIF
endwhile
endif
endif
fclose 0
MACStart = 1 ;Set Moves and Changes Integer
;prepare failure message file & string before strings are altered with ENTER key at end
Temp_End = "FAILURE - MAC's NOT COMPLETED! "
if fopen 1 F_Erra CREATE TEXT ;open NEWfile for ReadWrite
fputs 1 Temp_End
Temp_Str = "1st Orig TN:"
strcat Temp_Str AAATNSwap
fputs 1 Temp_Str
strcat Temp_End Temp_Str
strcat Temp_End ","
Temp_Str = "1st Orig DN:"
strcat Temp_Str AOrigDN
fputs 1 Temp_Str
strcat Temp_End Temp_Str
strcat Temp_End ","
Temp_Str = "1st swap TN:"
strcat Temp_Str ASpareTN
fputs 1 Temp_Str
strcat Temp_End Temp_Str
strcat Temp_End ","
Temp_Str = "1st Spare DN:"
strcat Temp_Str ASpareDN
fputs 1 Temp_Str
strcat Temp_End Temp_Str
strcat Temp_End "."
Temp_Str = "2nd Orig TN:"
strcat Temp_Str BBBTNSwap
fputs 1 Temp_Str
strcat Temp_End Temp_Str
strcat Temp_End ","
Temp_Str = "2nd Orig DN:"
strcat Temp_Str BOrigDN
fputs 1 Temp_Str
strcat Temp_End Temp_Str
strcat Temp_End ","
Temp_Str = "2nd swap TN:"
strcat Temp_Str BSpareTN
fputs 1 Temp_Str
strcat Temp_End Temp_Str
strcat Temp_End ","
Temp_Str = "2nd Spare DN:"
strcat Temp_Str BSpareDN
fputs 1 Temp_Str
strcat Temp_End Temp_Str
strcat Temp_End "."
Temp_Str = " MANUAL INTERVENTION & CORRECTION REQUIRED."
fputs 1 Temp_Str
strcat Temp_End Temp_Str
mspause 300
fclose 1
endif
;add ^M to strings
strcat AAATNSwap "^M"
strcat ASpareTN "^M"
strcat ASpareDN "^M"
strcat BBBTNSwap "^M"
strcat BSpareTN "^M"
strcat BSpareDN "^M"
strcat AOrigDN "^M"
strcat BOrigDN "^M"
;COPY From 1st TN - 1st Spare using 1st Spare DN
STATMSG "Copy from 1st TN to 1st Spare..."
transmit "CPY 1^M"
waitfor "TYPE:" FOREVER
Temp_Str = AAAType
transmit Temp_Str
waitfor "CFTN" FOREVER
transmit AAATNSwap
waitfor "TN" FOREVER
transmit ASpareTN
waitfor "DN" FOREVER
transmit ASpareDN
waitfor "*** FINISHED ***" FOREVER
waitquiet 1
;COPY From 2nd TN - 2nd Spare using 2nd Spare DN
STATMSG "Copy from 2nd TN to 2nd Spare..."
transmit "CPY 1^M"
waitfor "TYPE:" FOREVER
Temp_Str = BBBType
transmit Temp_Str
waitfor "CFTN" FOREVER
transmit BBBTNSwap
waitfor "TN" FOREVER
transmit BSpareTN
waitfor "DN" FOREVER
transmit BSpareDN
waitfor "*** FINISHED ***" FOREVER
waitquiet 1
;OUT 1st Orig TN
STATMSG "OUT 1st Orig TN..."
transmit "OUT^M"
waitfor "TYPE:" FOREVER
Temp_Str = BBBType
transmit Temp_Str
waitfor "TN" FOREVER
transmit AAATNSwap
waitfor "REQ:" FOREVER
waitquiet 1
;OUT 2nd Orig TN
STATMSG "OUT 2nd Orig TN..."
transmit "OUT^M"
waitfor "TYPE:" FOREVER
Temp_Str = BBBType
transmit Temp_Str
waitfor "TN" FOREVER
transmit BBBTNSwap
waitfor "REQ:" FOREVER
waitquiet 1
;COPY From 1st Spare TN - 2nd Orig TN using 1st Orig DN
STATMSG "COPY From 1st Spare TN - 2nd Orig TN using 1st Orig DN..."
transmit "CPY 1^M"
waitfor "TYPE:" FOREVER
Temp_Str = AAAType
transmit Temp_Str
waitfor "CFTN" FOREVER
transmit ASpareTN
waitfor "TN" FOREVER
transmit BBBTNSwap
waitfor "DN" FOREVER
transmit AOrigDN
waitfor "*** FINISHED ***" FOREVER
waitquiet 1
;COPY From 2nd Spare TN - 1st Orig TN using 2nd DN
STATMSG "COPY From 2nd Spare TN - 1st Orig TN using 2nd DN..."
transmit "CPY 1^M"
waitfor "TYPE:" FOREVER
Temp_Str = BBBType
transmit Temp_Str
waitfor "CFTN" FOREVER
transmit BSpareTN
waitfor "TN" FOREVER
transmit AAATNSwap
waitfor "DN" FOREVER
transmit BOrigDN
waitfor "*** FINISHED ***" FOREVER
waitquiet 1
;OUT 1st SPARE TN
STATMSG "OUT 1st SPARE TN"
transmit "OUT^M"
waitfor "TYPE:" FOREVER
Temp_Str = AAAType
transmit Temp_Str
waitfor "TN" FOREVER
transmit ASpareTN
waitfor "REQ:" FOREVER
waitquiet 1
;OUT 2nd SPARE TN
STATMSG "OUT 2nd SPARE TN"
transmit "OUT^M"
waitfor "TYPE:" FOREVER
Temp_Str = AAAType
transmit Temp_Str
waitfor "TN" FOREVER
transmit BSpareTN
waitfor "REQ:" FOREVER
waitquiet 1
;END OF SCRIPT
transmit "PRT^M"
waitfor "TYPE:" FOREVER
transmit "TNB^M"
waitfor "TN" FOREVER
transmit AAATNSwap
waitfor "DATE" FOREVER
transmit "^M"
waitfor "PAGE" FOREVER
transmit "^M"
waitfor "DES" FOREVER
transmit "^M"
waitquiet 2 FOREVER
transmit "^M"
transmit "PRT^M"
waitfor "TYPE:" FOREVER
transmit "TNB^M"
waitfor "TN" FOREVER
transmit BBBTNSwap
waitfor "DATE" FOREVER
transmit "^M"
waitfor "PAGE" FOREVER
transmit "^M"
waitfor "DES" FOREVER
transmit "^M"
waitquiet 2 FOREVER
transmit "^M"
MACStart = 3
call term
endproc
proc findtype
;capture screen display to file
set capture file FNameCap ; Set name of capture file.
set capture overwrite ON
capture on ; Open up the capture file.
;the input TN should be formatted L<space>S<space>C<space>U
Temp_Str = "STAT "
strextract Swap_Str XXXTNSwap " " 0 ;extract Loop
strcat Temp_Str Swap_Str ;obtain L
Str_Temp = Swap_Str
strcat Temp_Str " "
strextract Swap_Str XXXTNSwap " " 1 ;extract Shelf
strcat Temp_Str Swap_Str ;obtain L S
strcat Temp_Str " "
strextract Swap_Str XXXTNSwap " " 2 ;extract Card
strcat Temp_Str Swap_Str ;obtain L S C
strcat Temp_Str "^M"
mspause 250
transmit Temp_Str
waitfor "REQ:" 3
capture off ; Close capture file.
strextract Swap_Str XXXTNSwap " " 3 ;extract Unit
strreplace Swap_Str "`n" "" ;strip new line string
strreplace Swap_Str "`r" "" ;strip return string
strlen Swap_Str Len
mspause 250
if Len < 2
if NOT rstrcmp Swap_Str "0" 1 ;1st char NOT 0
;then prefix it with 0 for 01-09
Temp_Str = Swap_Str
Swap_Str = "0"
strcat Swap_Str Temp_Str
endif
endif
;playback from capture file
FNameCap = "C:\Program Files\Symantec\Procomm Plus\Capture\deleteme.txt"
if isfile FNameCap ; Make sure file exists.
if fopen 0 FNameCap READ ; Open file for read.
while not feof 0 ; Loop to end of file.
fgets 0 LineInfo ; Get line from file.
if rstrcmp LineInfo Swap_Str 2 ;1st 2 chars match Unit
substr Temp_Str LineInfo 22 4 ;so get the TYPE
strcat Temp_Str "^M"
strreplace Temp_Str "L" "" ;remove L from L500
endif
endwhile
endif
endif
endproc
proc term
transmit "****^M"
mspause 250
IF MACStart == 1 ;Changes have started but not completed due to user exit
USERMSG Temp_End ;Reminder Error Message
ENDIF
IF MACStart == 3 ; Changes completed OK
;we have no errors.
Temp_Str = "Script completed Succesfully. The programming for those TNs has been swapped."
if fopen 1 F_Erra CREATE TEXT ;open NEWfile for ReadWrite
fputs 1 Temp_Str
fclose 1
endif
ENDIF
IF MACStart == 0 ; Script aborted before MACs started
Temp_Str = "Script aborted before MACs had started. The programming for those TNs has not been altered."
if fopen 1 F_Erra CREATE TEXT ;open NEWfile for ReadWrite
fputs 1 Temp_Str
fclose 1
endif
ENDIF
mspause 250
RUN F_Erra ;Open Error Messsage File
exit
endproc
;################################################################
;# TN_SWAP Procomm Script #
;# Author: Chris Jackson. #
;# Disclaimer: The script is provided without any warranty #
;# as to it's accuracy, reliability or suitability. #
;# #
;# This script will swap the programming between two TNs on #
;# NORTEL Meridian PABXs. It does this in the following manner. #
;# #
;# ASK USER for 1st TN #
;# CHECK 1st TN for INVALID CHARACTERS #
;# ASK USER for 2nd TN #
;# CHECK 2nd TN for INVALID CHARACTERS #
;# ASK USER FOR CONFIRMATION TO RUN SCRIPT #
;# CHECK TNs are VALID #
;# call to FINDTYPE procedure (to find TYPE) #
;# CHECK TYPES Match for TNs given #
;# CHECK SPARE TNs exist for TYPE #
;# GET ORIGINAL DNs by TNB|Screen capture|read from file #
;# and ACD DETECTION ! Script will abort if ACDs #
;# CHECK SPARE DNs exist #
;# #
;# Moves and Changes START #
;# COPY From 1st TN -> 1st Spare using 1st Spare DN #
;# COPY From 2nd TN -> 2nd Spare using 2nd Spare DN #
;# OUT 1st Orig TN #
;# OUT 2nd Orig TN #
;# COPY From 1st Spare TN -> 2nd Orig TN using 1st Orig DN #
;# COPY From 2nd Spare TN -> 1st Orig TN using 2nd Orig DN #
;# OUT 1st SPARE TN #
;# OUT 2nd SPARE TN #
;# #
;# FINDTYPE Procedure - Finds TYPE #
;# TERM Procedure - Runs before Exiting, Incl's Error Messages. #
;# #
;################################################################
integer Len
integer Choice = 0 ;user verification integer
integer verifile = 0 ;file contents verification integer
integer cnt_DN = 0 ;increment integer for DNs
integer DN_Len = 0 ;3 or 4 Digit DN Length integer
integer SpareDNs = 0 ;Spare DNs Integer
integer MACStart = 0 ;Moves & Changes detection integer
string AAATNSwap, BBBTNSwap, Temp_Str, Swap_Str, XXXTNSwap, LineInfo, Temp_End
string AAAType, BBBType, Str_Temp, AAA_LUVU, BBB_LUVU, ASpareTN, BSpareTN, ASpareDN, BSpareDN, AOrigDN, BOrigDN
string FNameCap = "deleteme.txt"
string F_Erra = "C:\Program Files\Symantec\Procomm Plus\Capture\Error.txt"
proc main
WHEN USEREXIT call TERM
;logout of any active LDs
transmit "****^M"
waitfor ">" 2
;ASK USER for 1st TN
sdlginput "TN SWAP" "Please Enter the 1st TN..." AAATNSwap 11 DEFAULT
IF FAILURE
call term
ENDIF
;CHECK 1st TN for INVALID CHARACTERS
IF strcspn AAATNSwap "0123456789"
;contains numbers
IF strcspn AAATNSwap "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~!@#$%^&*()_+-={}|[]\:";'<>?,./"
usermsg "1st TN Input INVALID CHARACTERS - %s" AAATNSwap
call term
ENDIF
ELSE
usermsg "1st TN Input INVALID CHARACTERS - %s" AAATNSwap
call term
ENDIF
;ASK USER for 2nd TN
sdlginput "TN SWAP" "Please Enter the 2nd TN..." BBBTNSwap 11 DEFAULT
IF FAILURE
call term
ENDIF
;CHECK 2nd TN for INVALID CHARACTERS
IF strcspn BBBTNSwap "0123456789"
;contains numbers
IF strcspn BBBTNSwap "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ~!@#$%^&*()_+-={}|[]\:";'<>?,./"
usermsg "2nd TN Input INVALID CHARACTERS - %s" BBBTNSwap
call term
ENDIF
ELSE
usermsg "2nd TN Input INVALID CHARACTERS - %s" BBBTNSwap
ENDIF
transmit "LD 20^M"
waitfor "REQ:" 2
;USER CONFIRMATION
Temp_Str = "Swap programming between TN's "
strcat Temp_Str AAATNSwap
strcat Temp_Str " & "
strcat Temp_Str BBBTNSwap
strcat Temp_Str "?"
while Choice <= 5 ; Loop while user doesn't choose.
sdlgmsgbox " ### WARNING ! ###" Temp_Str QUESTION YESNO Choice 2
yield
endwhile
if Choice == 7 ; See if user said no.
call term
endif
;CHECK TNs are VALID
STATMSG "Checking TNs are VALID..."
XXXTNSwap = AAATNSwap
call findtype
AAAType = Temp_Str ;TYPE as found in called procedure
XXXTNSwap = BBBTNSwap
AAA_LUVU = Str_Temp ;Loop info to check for unused units
call findtype
BBBType = Temp_Str ;TYPE as found in called procedure
BBB_LUVU = Str_Temp ;Alternate Loop to check for unused units
;CHECK TN TYPES Match
STATMSG "Checking TN TYPEs MATCH..."
if NOT strcmp AAAType BBBType
Temp_Str = "TN TYPE's DO NOT MATCH. "
strcat Temp_Str AAAType
strcat Temp_Str " | "
strcat Temp_Str BBBType
ERRORMSG "%s" Temp_Str
call term
endif
;CHECK SPARE TNs exist for Type (LUVU) (LD 20)
STATMSG "Checking SPARE TNs exist..."
mspause 250
FNameCap = "deleteme.txt"
;capture screen display to file
set capture file FNameCap ; Set name of capture file.
set capture overwrite ON
capture on ; Open up the capture file.
transmit "LUVU^M"
waitfor "TYPE:" FOREVER
Temp_Str = AAAType
transmit Temp_Str
waitfor "TN" FOREVER
Temp_Str = AAA_LUVU
strcat Temp_Str "^M"
transmit Temp_Str
waitfor "CDEN" FOREVER
transmit "^M"
;repeat for Loop from 2nd TN
waitfor "REQ:" FOREVER
transmit "LUVU^M"
waitfor "TYPE:" FOREVER
Temp_Str = BBBType
transmit Temp_Str
waitfor "TN" FOREVER
Temp_Str = BBB_LUVU
strcat Temp_Str "^M"
transmit Temp_Str
waitfor "CDEN" FOREVER
transmit "^M"
waitfor "REQ:" FOREVER
capture off ; Close the capture file.
mspause 250
;playback from capture file
FNameCap = "C:\Program Files\Symantec\Procomm Plus\Capture\deleteme.txt"
if isfile FNameCap ; Make sure file exists.
if fopen 0 FNameCap READ ; Open file for read.
while not feof 0 ; Loop to end of file.
fgets 0 LineInfo ; Get line from file.
if rstrcmp LineInfo "REQ: LUVU" 9 ;1st 9 chars match
verifile = 1 ;verification of file contents
endif
if rstrcmp LineInfo "TYPE " 5 ;1st 5 chars match
;order of below scripts intentional to obtain TNs from different lines
if verifile == 2 ;verification of file contents & that we have 1 TN already
substr BSpareTN LineInfo 14 11 ;extract TN info
verifile ++
endif
if verifile == 1 ;verification of file contents
substr ASpareTN LineInfo 14 11 ;extract TN info
verifile ++
endif
endif
endwhile
endif
endif
fclose 0
if verifile != 3 ;we DON'T have both Spare TN Info's
USERMSG "Unable to obtain 2 Spare TN's."
call term
endif
;GET ORIGINAL DNs by TNB|Screen capture|read from file/ACD DETECTION!
STATMSG "Obtaining Original DNs..."
mspause 250
FNameCap = "deleteme.txt"
;capture screen display to file
set capture file FNameCap ; Set name of capture file.
set capture overwrite ON
capture on ; Open up the capture file.
transmit "PRT^M"
waitfor "TYPE:" FOREVER
transmit "TNB^M"
waitfor "TN" FOREVER
transmit AAATNswap
mspause 300
transmit "^M"
waitfor "DATE" FOREVER
transmit "^M"
waitfor "PAGE" FOREVER
transmit "^M"
waitfor "DES" FOREVER
transmit "^M"
waitquiet 2 FOREVER
transmit "^M"
;repeat for 2nd TN
transmit "PRT^M"
waitfor "TYPE:" FOREVER
transmit "TNB^M"
waitfor "TN" FOREVER
transmit BBBTNswap
mspause 300
transmit "^M"
waitfor "DATE" FOREVER
transmit "^M"
waitfor "PAGE" FOREVER
transmit "^M"
waitfor "DES" FOREVER
transmit "^M"
waitquiet 2 FOREVER
transmit "^M"
capture off ; Close the capture file.
mspause 250
;playback from capture file
FNameCap = "C:\Program Files\Symantec\Procomm Plus\Capture\deleteme.txt"
if isfile FNameCap ; Make sure file exists.
if fopen 0 FNameCap READ ; Open file for read.
while not feof 0 ; Loop to end of file.
fgets 0 LineInfo ; Get line from file.
if cnt_DN == 1 ;we have 1st DN / obtain 2nd DN
;this needs to appear above cnt_DN = 0
if rstrcmp LineInfo "DN " 5 ;1st 5 chars match
substr BOrigDN LineInfo 5 4
cnt_DN ++
endif
if rstrcmp LineInfo "KEY 00 SC" 9 ;1st 9 chars match
substr BOrigDN LineInfo 12 4
cnt_DN ++
endif
endif
if cnt_DN == 0 ;we have no DN info yet
if rstrcmp LineInfo "DN " 5 ;1st 5 chars match
substr AOrigDN LineInfo 5 4
cnt_DN ++
endif
if rstrcmp LineInfo "KEY 00 SC" 9 ;1st 9 chars match
substr AOrigDN LineInfo 12 4
cnt_DN ++
endif
endif
;### Detect if TYPE = ACD ###
if rstrcmp LineInfo "KEY 00 ACD" 11 ;1st 11 chars match
fclose 0 ;close file
USERMSG "Nortel Networks does not support the use of CPY command on ACD agents. Script will abort."
call term ;exit
endif
;### end of ACD detection ###
;determine if Orig DNs are 3 or 4 Digit.
IF strchr AOrigDN ' ' ;DN info contains a SPACE
DN_Len = 3
ELSE
DN_Len = 4
ENDIF
IF strchr BOrigDN ' ' ;DN info contains a SPACE
DN_Len = 3
ELSE
DN_Len = 4
ENDIF
endwhile
endif
endif
fclose 0
;CHECK SPARE DNs exist
STATMSG "Checking SPARE DNs exist..."
mspause 250
FNameCap = "deleteme.txt"
;capture screen display to file
set capture file FNameCap ; Set name of capture file.
set capture overwrite ON
capture on ; Open up the capture file.
transmit "PRT^M"
waitfor "TYPE:" FOREVER
transmit "LUDN^M"
waitfor "CUST" FOREVER
transmit "^M"
waitfor "DN" FOREVER
;obtain 1st Digit of 1st OrigDN
substr Temp_Str AOrigDN 0 1
strcat Temp_Str "^M"
transmit Temp_Str
waitquiet 2
;repeat for 2nd Orig DN
transmit "PRT^M"
waitfor "TYPE:" FOREVER
transmit "LUDN^M"
waitfor "CUST" FOREVER
transmit "^M"
waitfor "DN" FOREVER
;obtain 1st Digit of 2nd OrigDN
substr Swap_Str BOrigDN 0 1
strcat Swap_Str "^M"
transmit Swap_Str
waitquiet 2
capture off
pause 2
;playback from capture file
FNameCap = "C:\Program Files\Symantec\Procomm Plus\Capture\deleteme.txt"
if isfile FNameCap ; Make sure file exists.
if fopen 0 FNameCap READ ; Open file for read.
while not feof 0 ; Loop to end of file.
fgets 0 LineInfo ; Get line from file.
IF SpareDNs == 1 ;this script needs to appear before SpareDNs value is set to 1
if rstrcmp LineInfo Temp_Str 1 ;1st char matches
strextract ASpareDn LineInfo " " 0 ;Extract 1st Spare DN from 1st Col Pos
endif
if rstrcmp LineInfo Swap_Str 1 ;1st char matches
strextract BSpareDn LineInfo " " 1 ;Extract 2nd Spare DN from 2nd Col Pos
endif
SpareDNs = 2
ENDIF
IF SpareDNs == 0 ;required to ensure trigger once only
IF strfind LineInfo "CUSTOMER 00 - UNUSED DNS:" ;Capture file verified
SpareDNs = 1
ENDIF
ENDIF
endwhile
endif
endif
fclose 0
MACStart = 1 ;Set Moves and Changes Integer
;prepare failure message file & string before strings are altered with ENTER key at end
Temp_End = "FAILURE - MAC's NOT COMPLETED! "
if fopen 1 F_Erra CREATE TEXT ;open NEWfile for ReadWrite
fputs 1 Temp_End
Temp_Str = "1st Orig TN:"
strcat Temp_Str AAATNSwap
fputs 1 Temp_Str
strcat Temp_End Temp_Str
strcat Temp_End ","
Temp_Str = "1st Orig DN:"
strcat Temp_Str AOrigDN
fputs 1 Temp_Str
strcat Temp_End Temp_Str
strcat Temp_End ","
Temp_Str = "1st swap TN:"
strcat Temp_Str ASpareTN
fputs 1 Temp_Str
strcat Temp_End Temp_Str
strcat Temp_End ","
Temp_Str = "1st Spare DN:"
strcat Temp_Str ASpareDN
fputs 1 Temp_Str
strcat Temp_End Temp_Str
strcat Temp_End "."
Temp_Str = "2nd Orig TN:"
strcat Temp_Str BBBTNSwap
fputs 1 Temp_Str
strcat Temp_End Temp_Str
strcat Temp_End ","
Temp_Str = "2nd Orig DN:"
strcat Temp_Str BOrigDN
fputs 1 Temp_Str
strcat Temp_End Temp_Str
strcat Temp_End ","
Temp_Str = "2nd swap TN:"
strcat Temp_Str BSpareTN
fputs 1 Temp_Str
strcat Temp_End Temp_Str
strcat Temp_End ","
Temp_Str = "2nd Spare DN:"
strcat Temp_Str BSpareDN
fputs 1 Temp_Str
strcat Temp_End Temp_Str
strcat Temp_End "."
Temp_Str = " MANUAL INTERVENTION & CORRECTION REQUIRED."
fputs 1 Temp_Str
strcat Temp_End Temp_Str
mspause 300
fclose 1
endif
;add ^M to strings
strcat AAATNSwap "^M"
strcat ASpareTN "^M"
strcat ASpareDN "^M"
strcat BBBTNSwap "^M"
strcat BSpareTN "^M"
strcat BSpareDN "^M"
strcat AOrigDN "^M"
strcat BOrigDN "^M"
;COPY From 1st TN - 1st Spare using 1st Spare DN
STATMSG "Copy from 1st TN to 1st Spare..."
transmit "CPY 1^M"
waitfor "TYPE:" FOREVER
Temp_Str = AAAType
transmit Temp_Str
waitfor "CFTN" FOREVER
transmit AAATNSwap
waitfor "TN" FOREVER
transmit ASpareTN
waitfor "DN" FOREVER
transmit ASpareDN
waitfor "*** FINISHED ***" FOREVER
waitquiet 1
;COPY From 2nd TN - 2nd Spare using 2nd Spare DN
STATMSG "Copy from 2nd TN to 2nd Spare..."
transmit "CPY 1^M"
waitfor "TYPE:" FOREVER
Temp_Str = BBBType
transmit Temp_Str
waitfor "CFTN" FOREVER
transmit BBBTNSwap
waitfor "TN" FOREVER
transmit BSpareTN
waitfor "DN" FOREVER
transmit BSpareDN
waitfor "*** FINISHED ***" FOREVER
waitquiet 1
;OUT 1st Orig TN
STATMSG "OUT 1st Orig TN..."
transmit "OUT^M"
waitfor "TYPE:" FOREVER
Temp_Str = BBBType
transmit Temp_Str
waitfor "TN" FOREVER
transmit AAATNSwap
waitfor "REQ:" FOREVER
waitquiet 1
;OUT 2nd Orig TN
STATMSG "OUT 2nd Orig TN..."
transmit "OUT^M"
waitfor "TYPE:" FOREVER
Temp_Str = BBBType
transmit Temp_Str
waitfor "TN" FOREVER
transmit BBBTNSwap
waitfor "REQ:" FOREVER
waitquiet 1
;COPY From 1st Spare TN - 2nd Orig TN using 1st Orig DN
STATMSG "COPY From 1st Spare TN - 2nd Orig TN using 1st Orig DN..."
transmit "CPY 1^M"
waitfor "TYPE:" FOREVER
Temp_Str = AAAType
transmit Temp_Str
waitfor "CFTN" FOREVER
transmit ASpareTN
waitfor "TN" FOREVER
transmit BBBTNSwap
waitfor "DN" FOREVER
transmit AOrigDN
waitfor "*** FINISHED ***" FOREVER
waitquiet 1
;COPY From 2nd Spare TN - 1st Orig TN using 2nd DN
STATMSG "COPY From 2nd Spare TN - 1st Orig TN using 2nd DN..."
transmit "CPY 1^M"
waitfor "TYPE:" FOREVER
Temp_Str = BBBType
transmit Temp_Str
waitfor "CFTN" FOREVER
transmit BSpareTN
waitfor "TN" FOREVER
transmit AAATNSwap
waitfor "DN" FOREVER
transmit BOrigDN
waitfor "*** FINISHED ***" FOREVER
waitquiet 1
;OUT 1st SPARE TN
STATMSG "OUT 1st SPARE TN"
transmit "OUT^M"
waitfor "TYPE:" FOREVER
Temp_Str = AAAType
transmit Temp_Str
waitfor "TN" FOREVER
transmit ASpareTN
waitfor "REQ:" FOREVER
waitquiet 1
;OUT 2nd SPARE TN
STATMSG "OUT 2nd SPARE TN"
transmit "OUT^M"
waitfor "TYPE:" FOREVER
Temp_Str = AAAType
transmit Temp_Str
waitfor "TN" FOREVER
transmit BSpareTN
waitfor "REQ:" FOREVER
waitquiet 1
;END OF SCRIPT
transmit "PRT^M"
waitfor "TYPE:" FOREVER
transmit "TNB^M"
waitfor "TN" FOREVER
transmit AAATNSwap
waitfor "DATE" FOREVER
transmit "^M"
waitfor "PAGE" FOREVER
transmit "^M"
waitfor "DES" FOREVER
transmit "^M"
waitquiet 2 FOREVER
transmit "^M"
transmit "PRT^M"
waitfor "TYPE:" FOREVER
transmit "TNB^M"
waitfor "TN" FOREVER
transmit BBBTNSwap
waitfor "DATE" FOREVER
transmit "^M"
waitfor "PAGE" FOREVER
transmit "^M"
waitfor "DES" FOREVER
transmit "^M"
waitquiet 2 FOREVER
transmit "^M"
MACStart = 3
call term
endproc
proc findtype
;capture screen display to file
set capture file FNameCap ; Set name of capture file.
set capture overwrite ON
capture on ; Open up the capture file.
;the input TN should be formatted L<space>S<space>C<space>U
Temp_Str = "STAT "
strextract Swap_Str XXXTNSwap " " 0 ;extract Loop
strcat Temp_Str Swap_Str ;obtain L
Str_Temp = Swap_Str
strcat Temp_Str " "
strextract Swap_Str XXXTNSwap " " 1 ;extract Shelf
strcat Temp_Str Swap_Str ;obtain L S
strcat Temp_Str " "
strextract Swap_Str XXXTNSwap " " 2 ;extract Card
strcat Temp_Str Swap_Str ;obtain L S C
strcat Temp_Str "^M"
mspause 250
transmit Temp_Str
waitfor "REQ:" 3
capture off ; Close capture file.
strextract Swap_Str XXXTNSwap " " 3 ;extract Unit
strreplace Swap_Str "`n" "" ;strip new line string
strreplace Swap_Str "`r" "" ;strip return string
strlen Swap_Str Len
mspause 250
if Len < 2
if NOT rstrcmp Swap_Str "0" 1 ;1st char NOT 0
;then prefix it with 0 for 01-09
Temp_Str = Swap_Str
Swap_Str = "0"
strcat Swap_Str Temp_Str
endif
endif
;playback from capture file
FNameCap = "C:\Program Files\Symantec\Procomm Plus\Capture\deleteme.txt"
if isfile FNameCap ; Make sure file exists.
if fopen 0 FNameCap READ ; Open file for read.
while not feof 0 ; Loop to end of file.
fgets 0 LineInfo ; Get line from file.
if rstrcmp LineInfo Swap_Str 2 ;1st 2 chars match Unit
substr Temp_Str LineInfo 22 4 ;so get the TYPE
strcat Temp_Str "^M"
strreplace Temp_Str "L" "" ;remove L from L500
endif
endwhile
endif
endif
endproc
proc term
transmit "****^M"
mspause 250
IF MACStart == 1 ;Changes have started but not completed due to user exit
USERMSG Temp_End ;Reminder Error Message
ENDIF
IF MACStart == 3 ; Changes completed OK
;we have no errors.
Temp_Str = "Script completed Succesfully. The programming for those TNs has been swapped."
if fopen 1 F_Erra CREATE TEXT ;open NEWfile for ReadWrite
fputs 1 Temp_Str
fclose 1
endif
ENDIF
IF MACStart == 0 ; Script aborted before MACs started
Temp_Str = "Script aborted before MACs had started. The programming for those TNs has not been altered."
if fopen 1 F_Erra CREATE TEXT ;open NEWfile for ReadWrite
fputs 1 Temp_Str
fclose 1
endif
ENDIF
mspause 250
RUN F_Erra ;Open Error Messsage File
exit
endproc