Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Swap DN/TN script needed please 1

Status
Not open for further replies.

motox2

Programmer
Jun 21, 2007
426
0
0
GY
Hi there, i have an 81-c that im looking for a GUI type script to use to swap TN's. I have alot of this type work to do and i thought a script would help move it on a little easier. Thank you
 
scripts are usually command line, you can build one that works via an icon but i don't usually waste time on dressing them up that far.. your just looking for a swap sets or a echg on the dn of stations?

john poole
bellsouth business
columbia,sc
 
It is not a GUI Script, but here is a Procomm Script I wrote to swap the programming between two TN's.

I created two TNs to mess with. 4 0 8 4 (DN-1204), 4 0 8 5 (DN-1205).
The script works 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)
FINDTYPE Procedure - Finds 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 KEY 00 ACD
CHECK SPARE DNs exist
Moves and Changes then START
CPY From 1st TN -> 1st Spare using 1st Spare DN
CPY 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
TERM Procedure - Runs before Exiting,
Incl's Error Messages.


I run the script, input 4 0 8 4, 4 0 8 5 into 2 text boxes. The script then ran as follows....
Screen Buffer_______________________________
REQ: ****
OVL000
>LD 20

PT0000
REQ: STAT 4 0 8
00 = UNIT 00 = IDLE (L500)
01 = UNIT 01 = IDLE (L500)
02 = UNIT 02 = IDLE (L500)
03 = UNIT 03 = UNEQ
04 = UNIT 04 = IDLE (L500)
05 = UNIT 05 = IDLE (L500)
06 = UNIT 06 = UNEQ
07 = UNIT 07 = UNEQ
08 = UNIT 08 = UNEQ
09 = UNIT 09 = UNEQ
10 = UNIT 10 = UNEQ
11 = UNIT 11 = UNEQ
12 = UNIT 12 = UNEQ
13 = UNIT 13 = UNEQ
14 = UNIT 14 = UNEQ
15 = UNIT 15 = UNEQ
REQ: STAT 4 0 8
00 = UNIT 00 = IDLE (L500)
01 = UNIT 01 = IDLE (L500)
02 = UNIT 02 = IDLE (L500)
03 = UNIT 03 = UNEQ
04 = UNIT 04 = IDLE (L500)
05 = UNIT 05 = IDLE (L500)
06 = UNIT 06 = UNEQ
07 = UNIT 07 = UNEQ
08 = UNIT 08 = UNEQ
09 = UNIT 09 = UNEQ
10 = UNIT 10 = UNEQ
11 = UNIT 11 = UNEQ
12 = UNIT 12 = UNEQ
13 = UNIT 13 = UNEQ
14 = UNIT 14 = UNEQ
15 = UNIT 15 = UNEQ
REQ: LUVU
TYPE: 500

TN 4
CDEN
TYPE 500 TN 004 0 08 03 4D
TYPE 500 TN 004 0 08 06 4D
TYPE 500 TN 004 0 08 07 4D
TYPE 500 TN 004 0 08 08 4D
TYPE 500 TN 004 0 08 09 4D
TYPE 500 TN 004 0 08 10 4D
TYPE 500 TN 004 0 08 11 4D
TYPE 500 TN 004 0 08 12 4D
TYPE 500 TN 004 0 08 13 4D
TYPE 500 TN 004 0 08 14 4D
TYPE 500 TN 004 0 08 15 4D


REQ: LUVU
TYPE: 500
TN 4
CDEN
TYPE 500 TN 004 0 08 03 4D
TYPE 500 TN 004 0 08 06 4D
TYPE 500 TN 004 0 08 07 4D
TYPE 500 TN 004 0 08 08 4D
TYPE 500 TN 004 0 08 09 4D
TYPE 500 TN 004 0 08 10 4D
TYPE 500 TN 004 0 08 11 4D
TYPE 500 TN 004 0 08 12 4D
TYPE 500 TN 004 0 08 13 4D
TYPE 500 TN 004 0 08 14 4D
TYPE 500 TN 004 0 08 15 4D


REQ: PRT
TYPE: TNB
TN 4 0 8 4
DATE
PAGE
DES

DES 4084
TN 004 0 08 04
TYPE 500
CDEN 4D
CUST 0
WRLS NO
DN 1204 0 MARP
AST NO
IAPG 0
HUNT
TGAR 1
LDN NO
NCOS 0
SGRP 0
RNPG 0
XLST
SCI 0
SCPW
SFLT NO
CAC_MFC 0
CLS CTD DTN FBD XFD WTA THFD FND HTD ONS
LPR XRD AGRD CWD SWD MWD RMMD SMWD LPD XHD SLKD CCSD LND TVD
CFTD SFD MRD C6D CNID CLBD AUTU
ICDD CDMD LLCN EHTD MCTD
GPUD DPUD CFXD ARHD OVDD AGTD CLTD LDTD ASCD
MBXD CPFA CPTA UDI RCC HBTD DDGA NAMA MIND
NRWD NRCD NROD CRD PRSD MCRD
EXR0 SHL ABDD CFHD DNDY DNO3
CWND USRD BNRD OCBD RTDD RBDD RBHD FAXD CNUD CNAD PGND FTTC
FDSD NOVD CDMR
PLEV 02
CSDN
AACS NO
MLWU_LANG 0
DATE 22 SEP 2007


NACT
REQ: PRT
TYPE: TNB
TN 4 0 8 5
DATE
PAGE
DES

DES 4085
TN 004 0 08 05
TYPE 500
CDEN 4D
CUST 0
WRLS NO
DN 1205 0 MARP
AST NO
IAPG 0
HUNT
TGAR 1
LDN NO
NCOS 0
SGRP 0
RNPG 0
XLST
SCI 0
SCPW
SFLT NO
CAC_MFC 0
CLS CTD DTN FBD XFD WTA THFD FND HTD ONS
LPR XRD AGRD CWD SWD MWD RMMD SMWD LPD XHD SLKD CCSD LND TVD
CFTD SFD MRD C6D CNID CLBD AUTU
ICDD CDMD LLCN EHTD MCTD
GPUD DPUD CFXD ARHD OVDD AGTD CLTD LDTD ASCD
MBXD CPFA CPTA UDI RCC HBTD DDGA NAMA MIND
NRWD NRCD NROD CRD PRSD MCRD
EXR0 SHL ABDD CFHD DNDY DNO3
CWND USRD BNRD OCBD RTDD RBDD RBHD FAXD CNUD CNAD PGND FTTC
FDSD NOVD CDMR
PLEV 02
CSDN
AACS NO
MLWU_LANG 0
DATE 22 SEP 2007


NACT
REQ: PRT
TYPE: LUDN
CUST
DN 1

CUSTOMER 00 - UNUSED DNS:
1029 1051 1063 1166 1215 1321 1347 1362 1376 1384
1388 1404 1488 1519 1554 1580 1620 1641 1669 1681
1740 1753 1795 1875 1895 1914 1961 1974

REQ: PRT
TYPE: LUDN
CUST
DN 1

CUSTOMER 00 - UNUSED DNS:
1029 1051 1063 1166 1215 1321 1347 1362 1376 1384
1388 1404 1488 1519 1554 1580 1620 1641 1669 1681
1740 1753 1795 1875 1895 1914 1961 1974

REQ: CPY 1
TYPE: 500
CFTN 4 0 8 4
DES 4084

*** MAKE PRINTER READY ***
TN 004 0 08 03
DN 1029

NEW 500 TN 004 0 08 03 DN 1029

SCH5525
*** FINISHED ***
MEM AVAIL: (U/P): 47722707 USED U P: 3159429 731556 TOT: 51613692
DISK SPACE NEEDED: 1215 KBYTES
ANALOGUE TELEPHONES AVAIL: 3149 USED: 2477 TOT: 5626
CLASS TELEPHONES AVAIL: 30000 USED: 0 TOT: 30000
WIRELESS TELEPHONES AVAIL: 6 USED: 26 TOT: 32
WIRELESS VISITORS AVAIL: 0 USED: 0 TOT: 0
ACD AGENTS AVAIL: 104 USED: 178 TOT: 282
AST AVAIL: 4000 USED: 0 TOT: 4000
TNS AVAIL: 27232 USED: 5528 TOT: 32760
DATA PORTS AVAIL: 32759 USED: 1 TOT: 32760
PHANTOM PORTS AVAIL: 32627 USED: 133 TOT: 32760

REQ: CPY 1
TYPE: 500
CFTN 4 0 8 5
DES 4085

*** MAKE PRINTER READY ***
TN 004 0 08 06
DN 1051

NEW 500 TN 004 0 08 06 DN 1051

SCH5525
*** FINISHED ***
MEM AVAIL: (U/P): 47722631 USED U P: 3159471 731590 TOT: 51613692
DISK SPACE NEEDED: 1215 KBYTES
ANALOGUE TELEPHONES AVAIL: 3148 USED: 2478 TOT: 5626
CLASS TELEPHONES AVAIL: 30000 USED: 0 TOT: 30000
WIRELESS TELEPHONES AVAIL: 6 USED: 26 TOT: 32
WIRELESS VISITORS AVAIL: 0 USED: 0 TOT: 0
ACD AGENTS AVAIL: 104 USED: 178 TOT: 282
AST AVAIL: 4000 USED: 0 TOT: 4000
TNS AVAIL: 27231 USED: 5529 TOT: 32760
DATA PORTS AVAIL: 32759 USED: 1 TOT: 32760
PHANTOM PORTS AVAIL: 32627 USED: 133 TOT: 32760

REQ: OUT
TYPE: 500
TN 4 0 8 4

MEM AVAIL: (U/P): 47722707 USED U P: 3159429 731556 TOT: 51613692
DISK SPACE NEEDED: 1215 KBYTES
ANALOGUE TELEPHONES AVAIL: 3149 USED: 2477 TOT: 5626
CLASS TELEPHONES AVAIL: 30000 USED: 0 TOT: 30000
WIRELESS TELEPHONES AVAIL: 6 USED: 26 TOT: 32
WIRELESS VISITORS AVAIL: 0 USED: 0 TOT: 0
ACD AGENTS AVAIL: 104 USED: 178 TOT: 282
AST AVAIL: 4000 USED: 0 TOT: 4000
TNS AVAIL: 27232 USED: 5528 TOT: 32760
DATA PORTS AVAIL: 32759 USED: 1 TOT: 32760
PHANTOM PORTS AVAIL: 32627 USED: 133 TOT: 32760

REQ: OUT
TYPE: 500
TN 4 0 8 5

MEM AVAIL: (U/P): 47722783 USED U P: 3159387 731522 TOT: 51613692
DISK SPACE NEEDED: 1215 KBYTES
ANALOGUE TELEPHONES AVAIL: 3150 USED: 2476 TOT: 5626
CLASS TELEPHONES AVAIL: 30000 USED: 0 TOT: 30000
WIRELESS TELEPHONES AVAIL: 6 USED: 26 TOT: 32
WIRELESS VISITORS AVAIL: 0 USED: 0 TOT: 0
ACD AGENTS AVAIL: 104 USED: 178 TOT: 282
AST AVAIL: 4000 USED: 0 TOT: 4000
TNS AVAIL: 27233 USED: 5527 TOT: 32760
DATA PORTS AVAIL: 32759 USED: 1 TOT: 32760
PHANTOM PORTS AVAIL: 32627 USED: 133 TOT: 32760

REQ: CPY 1
TYPE: 500
CFTN 004 0 08 03
DES 4084

*** MAKE PRINTER READY ***
TN 4 0 8 5
DN 1204

NEW 500 TN 004 0 08 05 DN 1204

SCH5525
*** FINISHED ***
MEM AVAIL: (U/P): 47722707 USED U P: 3159429 731556 TOT: 51613692
DISK SPACE NEEDED: 1215 KBYTES
ANALOGUE TELEPHONES AVAIL: 3149 USED: 2477 TOT: 5626
CLASS TELEPHONES AVAIL: 30000 USED: 0 TOT: 30000
WIRELESS TELEPHONES AVAIL: 6 USED: 26 TOT: 32
WIRELESS VISITORS AVAIL: 0 USED: 0 TOT: 0
ACD AGENTS AVAIL: 104 USED: 178 TOT: 282
AST AVAIL: 4000 USED: 0 TOT: 4000
TNS AVAIL: 27232 USED: 5528 TOT: 32760
DATA PORTS AVAIL: 32759 USED: 1 TOT: 32760
PHANTOM PORTS AVAIL: 32627 USED: 133 TOT: 32760

REQ: CPY 1
TYPE: 500
CFTN 004 0 08 06
DES 4085

*** MAKE PRINTER READY ***
TN 4 0 8 4
DN 1205

NEW 500 TN 004 0 08 04 DN 1205

SCH5525
*** FINISHED ***
MEM AVAIL: (U/P): 47722631 USED U P: 3159471 731590 TOT: 51613692
DISK SPACE NEEDED: 1215 KBYTES
ANALOGUE TELEPHONES AVAIL: 3148 USED: 2478 TOT: 5626
CLASS TELEPHONES AVAIL: 30000 USED: 0 TOT: 30000
WIRELESS TELEPHONES AVAIL: 6 USED: 26 TOT: 32
WIRELESS VISITORS AVAIL: 0 USED: 0 TOT: 0
ACD AGENTS AVAIL: 104 USED: 178 TOT: 282
AST AVAIL: 4000 USED: 0 TOT: 4000
TNS AVAIL: 27231 USED: 5529 TOT: 32760
DATA PORTS AVAIL: 32759 USED: 1 TOT: 32760
PHANTOM PORTS AVAIL: 32627 USED: 133 TOT: 32760

REQ: OUT
TYPE: 500
TN 004 0 08 03

MEM AVAIL: (U/P): 47722707 USED U P: 3159429 731556 TOT: 51613692
DISK SPACE NEEDED: 1215 KBYTES
ANALOGUE TELEPHONES AVAIL: 3149 USED: 2477 TOT: 5626
CLASS TELEPHONES AVAIL: 30000 USED: 0 TOT: 30000
WIRELESS TELEPHONES AVAIL: 6 USED: 26 TOT: 32
WIRELESS VISITORS AVAIL: 0 USED: 0 TOT: 0
ACD AGENTS AVAIL: 104 USED: 178 TOT: 282
AST AVAIL: 4000 USED: 0 TOT: 4000
TNS AVAIL: 27232 USED: 5528 TOT: 32760
DATA PORTS AVAIL: 32759 USED: 1 TOT: 32760
PHANTOM PORTS AVAIL: 32627 USED: 133 TOT: 32760

REQ: OUT
TYPE: 500
TN 004 0 08 06

MEM AVAIL: (U/P): 47722783 USED U P: 3159387 731522 TOT: 51613692
DISK SPACE NEEDED: 1215 KBYTES
ANALOGUE TELEPHONES AVAIL: 3150 USED: 2476 TOT: 5626
CLASS TELEPHONES AVAIL: 30000 USED: 0 TOT: 30000
WIRELESS TELEPHONES AVAIL: 6 USED: 26 TOT: 32
WIRELESS VISITORS AVAIL: 0 USED: 0 TOT: 0
ACD AGENTS AVAIL: 104 USED: 178 TOT: 282
AST AVAIL: 4000 USED: 0 TOT: 4000
TNS AVAIL: 27233 USED: 5527 TOT: 32760
DATA PORTS AVAIL: 32759 USED: 1 TOT: 32760
PHANTOM PORTS AVAIL: 32627 USED: 133 TOT: 32760

REQ: PRT
TYPE: TNB


TN 4 0 8 4
DATE
PAGE
DES

DES 4085
TN 004 0 08 04
TYPE 500
CDEN 4D
CUST 0
WRLS NO
DN 1205 0 MARP
AST NO
IAPG 0
HUNT
TGAR 1
LDN NO
NCOS 0
SGRP 0
RNPG 0
XLST
SCI 0
SCPW
SFLT NO
CAC_MFC 0
CLS CTD DTN FBD XFD WTA THFD FND HTD ONS
LPR XRD AGRD CWD SWD MWD RMMD SMWD LPD XHD SLKD CCSD LND TVD
CFTD SFD MRD C6D CNID CLBD AUTU
ICDD CDMD LLCN EHTD MCTD
GPUD DPUD CFXD ARHD OVDD AGTD CLTD LDTD ASCD
MBXD CPFA CPTA UDI RCC HBTD DDGA NAMA MIND
NRWD NRCD NROD CRD PRSD MCRD
EXR0 SHL ABDD CFHD DNDY DNO3
CWND USRD BNRD OCBD RTDD RBDD RBHD FAXD CNUD CNAD PGND FTTC
FDSD NOVD CDMR
PLEV 02
CSDN
AACS NO
MLWU_LANG 0
DATE 22 SEP 2007


NACT
REQ: PRT
TYPE: TNB
TN 4 0 8 5
DATE
PAGE
DES

DES 4084
TN 004 0 08 05
TYPE 500
CDEN 4D
CUST 0
WRLS NO
DN 1204 0 MARP
AST NO
IAPG 0
HUNT
TGAR 1
LDN NO
NCOS 0
SGRP 0
RNPG 0
XLST
SCI 0
SCPW
SFLT NO
CAC_MFC 0
CLS CTD DTN FBD XFD WTA THFD FND HTD ONS
LPR XRD AGRD CWD SWD MWD RMMD SMWD LPD XHD SLKD CCSD LND TVD
CFTD SFD MRD C6D CNID CLBD AUTU
ICDD CDMD LLCN EHTD MCTD
GPUD DPUD CFXD ARHD OVDD AGTD CLTD LDTD ASCD
MBXD CPFA CPTA UDI RCC HBTD DDGA NAMA MIND
NRWD NRCD NROD CRD PRSD MCRD
EXR0 SHL ABDD CFHD DNDY DNO3
CWND USRD BNRD OCBD RTDD RBDD RBHD FAXD CNUD CNAD PGND FTTC
FDSD NOVD CDMR
PLEV 02
CSDN
AACS NO
MLWU_LANG 0
DATE 22 SEP 2007


NACT
REQ: ****
OVL000
END Screen Buffer________________________________

Here is the Source File...

Code:
;################################################################
;#                  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
Yes! I have far too much time on my hands...

 
That cut'n'paste didn't go so well..
Here it is again...
Code:
;################################################################
;#                  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
Yes.. I have far too much time on my hands

 
Thats quite the script to mov 500 sets. Just MOV TN1 to a spare TN. Then MOV TN2 to TN1, and MOV Spare TN to TN2.

Scripts are great for some things, but swapping two TN's unless they are ACD, or some other monitored TN, sometimes the CLI commmand is just as quick, by time you find the script and get it kicked off.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top