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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Script - STAT & ENLU DSBL TN's from 1 input of all DN's. 1

Status
Not open for further replies.

comtechau

Technical User
Mar 24, 2007
81
AU
This might be a timesaver for anyone who regularly re-enables multiple TN's on Nortel Pabx's using Procomm.
Especially if you have just installed a heap of digital services.
I'm a fault desk guy for a large org' that has Nortel Pabx's we access with PROCOMM [via TELNET].


This procomm script will ENLU DSBL TN's.
You enter the DN/'s and it does the rest.


No more LD 20, prt, dnb, #### to get the TN's, STAT # # # #, ENLU # # # #.
This automates EVERYTHING!


It logs in , then I do a SINGLE input of the DN's in comma seperated format and watch it go..

e.g. 1111,1112,1113,1114,1115,1116<Enter>

*It should take up to 50 [in theory] 4 Digit DN's

It converts each DN > TN's, then STATs all TN's [I decided to incl key appearances].
DSBL TN's are re-enabled and STAT'd again.
Once finished all DN's the script logs out.

*Note: You MUST insert your own values for the following...
Telnet Connection Name
Telnet connection response prompt
Telnet connection password
logi username
logi password
DN Length.

Hope some of you find this as helpful as my colleagues and I.
regards, Chris.

my_photo.jpg


Code:
; script version 02 Apr, 2007.

;########################################################################################################
;#													#
;#   <<<<<	PLEASE ALTER THE VALUES BELOW TO REFLECT YOUR LOGIN USERNAMES/PASSWORDS   >>>>>		#
;#													#
;########################################################################################################

	   integer Length_DN = 4		; This is the length of the DN				
	   string TNStr 										
	   string Name_TNET = "Pabx TTY #" 	; Enter the name of your TELNET Dial Entry		
	   string Prmt_TNET = "#" 		; This is the prompt response from our TELNET Connection
	   string Pwrd_TNET = "itsasecret^M" 	; This is the password for our TELNET Connection	
	   string Name_PABX = "LOGI TECH^M"	; This is the username for the Pabx			
	   string Pwrd_PABX = "0000^M"		; This is the password for the Pabx			
  	   string DN_Length										
													
	
;########################################################################################################
;#		           script problems - ICQ: 1903368						#
;#													#
;#   This script will connect to a TTY Entry, then RESET Disabled TN's for DN's Entered. 		#	
;#													#
;#	MAIN 		-	Main Procedure								#
;#	PABXLOGI	-	Login to Pabx								#
;#	MIDN_END	-	Abort if MIDN activity detected						#
;#	STAT_TN   	-	Resolves DN's to TN's and STATs them					#
;#	ENLU_TN		-	Enables any disabled TN's						#
;#	TERM		-	Tidy Up on exit								#
;#													#
;#													#
;########################################################################################################





   
       
PROC MAIN  
   when TARGET 0 "OVL111 MIDN" call midn_end  ;this will end the script while MIDN ROUTINE 
   when USEREXIT call term  ;if user selects exit, call term then exit
   ;connect to tty 
   dial TELNET Name_TNET
   waitfor Prmt_TNET 15  
   mspause 250
   transmit Pwrd_TNET
   transmit "^M"
   waitfor "TTY" 2
   	IF SUCCESS
   	pause 1 ;PAUSE ADDED FOR MIDN Routine / SCH errors to be detected.
   	call pabxlogi
   	ELSE
		;TTY was left logged in
		transmit "****^M"
		call pabxlogi	
   	ENDIF
   call stat_tn	
   call term  
ENDPROC  

PROC PABXLOGI
   transmit Name_PABX
   waitfor "PASS?"
   transmit Pwrd_PABX
   waitfor ">"
ENDPROC

PROC MIDN_END
	errormsg "*** Midnight Routines Detected!! ***  - Script will abort."
	call term
ENDPROC
 
PROC STAT_TN
     integer nItem = 0
     integer Len
     string DirNums
     string CurDirN
     string EnterStr
     string FName            ; Name of capture file to open.
     string LineInfo                 ; Line from file.
     string STATStr
     string ENLUStr
     string InputInfo = "Enter  digit DN's seperated by a comma."
     
     when TARGET 9 "DSBL" call ENLU_TN
     
     STATStr = "STAT "
     ENLUStr = "ENLU " 
     Fname = "screen.txt"   ; Name of capture file to open.
     EnterStr = "^M"
     ;Run LD20
     transmit "LD 20^M"
     waitfor "REQ:" 
     itoa Length_DN DN_Length
     strinsert InputInfo DN_Length 6
     sdlginput "Auto' STAT and Enable TN's from DN's" InputInfo DirNums
     while 1  ; Loop forever, or until EXITWHILE.
     strextract CurDirN DirNums "," nItem
     if not nullstr CurDirN  ; See if we're at the end of list.
     
         ;This part of the script is where the DN's are resolved as TN's.
         transmit "prt^M"
         waitfor "TYPE:"
         transmit "dnb^M"
         waitfor "CUST"
         transmit "0^M"
         waitfor "DN"
         
         strlen CurDirN Len   ; Check length of text string.
         if Len == Length_DN ; if Len is correct perform action         
         	strcat CurDirN EnterStr
         	mspause 100
         	transmit CurDirN
	 	waitfor "DATE"
	 	transmit EnterStr
	 	waitfor "PAGE"
	 	transmit EnterStr
	 	waitfor "DES"
  	 	transmit EnterStr
	 	waitfor "NACT"
	 		
	 	;capture screen display to file
	 	set capture file FName    ; Set name of capture file.
	 	set capture overwrite ON
   		capture on                 ; Open up the capture file.
	 	transmit EnterStr
	 	waitfor "REQ:" 
 	 	capture off                ; Close the capture file.
		;playback from capture file
		
		FName = "C:\Program Files\Symantec\Procomm Plus\Capture\Screen.txt"
		if isfile FName              ; Make sure file exists.
 	       	   if fopen 0 FName READ     ; Open file for read.
        	     while not feof 0       ; Loop to end of file.
        	       fgets 0 LineInfo    ; Get line from file.
        	       
        	       		;check for existance of TN in line.	
        	       		if strfind LineInfo "TN"
        	       			;TN exists in the line so extract the TN String 			
        	       			strreplace LineInfo "TN   " "STAT " ;remove TN header and replace for STAT command
               	       			substr TNStr LineInfo 0 16 ;strip it off at end of TN numbers
               	       			strcat TNStr "^M" ;add ENTER
               	       			transmit TNStr
        	       			;responds with state of TN
        	       			waitfor "REQ:"
               	        	endif
               	     endwhile
        	     fclose 0               ; Close the file.
	            endif
	         else
	              errormsg "File doesn't exist."
	         endif
         else
         	transmit "****^M"
         	waitfor ">"
         	transmit "LD 20^M"
         	waitfor "REQ:"
         endif
         nItem++               ; Increment.
     else
         exitwhile             ; If blank file name, exit loop.
     endif
     endwhile
ENDPROC

PROC ENLU_TN
        mspause 250
	strreplace TNStr "STAT" "ENLU" ;remove STAT command and replace with ENLU command
	transmit TNStr
	waitfor "REQ:"
	strreplace TNStr "ENLU" "STAT" ;swap back commands
	transmit TNStr
	waitfor "REQ:" 3
	IF FAILURE
	USERMSG "TN WAS NOT SUCCESSFULLY RE-ENABLED"
	ENDIF        
ENDPROC

PROC TERM
   ;this procedure is run as a cleanup before exiting the script
   transmit "****"
   transmit "LOGO^M"
   waitquiet 1
   transmit "0^M"
   
   statmsg "Script Problems ? > ICQ: 1903368"
   disconnect
   exit
ENDPROC
 
AFTERTHOUGHT - THIS VERSION BELOW IS THE SAME SCRIPT WITHOUT THE AUTO LOG-IN/LOG-OFF.

TRY THIS FIRST TO SEE WHAT THE SCRIPT CAN DO.

You only need to EDIT the DN Length if it is not 4 Digits.

Code:
; script version 05 Apr, 2007.

;########################################################################################################
;#													#
;#   <<<<<		PLEASE ALTER THE DN LENGTH BELOW TO MATCH YOU PABX	   >>>>>		#
;#													#
;########################################################################################################

	   integer Length_DN = 4		; This is the length of the DN				
	   string TNStr 										
	   string DN_Length										
													
	
;########################################################################################################
;#		           script problems - ICQ: 1903368						#
;#													#
;#   This script will connect to a TTY Entry, then RESET Disabled TN's for DN's Entered. 		#	
;#													#
;#	MAIN 		-	Main Procedure								#
;#	STAT_TN   	-	Resolves DN's to TN's and STATs them					#
;#	ENLU_TN		-	Enables any disabled TN's						#
;#	TERM		-	Tidy Up on exit								#
;#													#
;#													#
;########################################################################################################





   
       
PROC MAIN  
   transmit "****^M" ;logout of any LD's
   waitfor ">"
   call stat_tn	
   call term  
ENDPROC  


PROC STAT_TN
     integer nItem = 0
     integer Len
     string DirNums
     string CurDirN
     string EnterStr
     string FName            ; Name of capture file to open.
     string LineInfo                 ; Line from file.
     string STATStr
     string ENLUStr
     string InputInfo = "Enter  digit DN's seperated by a comma."
     
     when TARGET 9 "DSBL" call ENLU_TN
     
     STATStr = "STAT "
     ENLUStr = "ENLU " 
     Fname = "screen.txt"   ; Name of capture file to open.
     EnterStr = "^M"
     ;Run LD20
     transmit "LD 20^M"
     waitfor "REQ:" 
     itoa Length_DN DN_Length
     strinsert InputInfo DN_Length 6
     sdlginput "Auto' STAT and Enable TN's from DN's" InputInfo DirNums
     while 1  ; Loop forever, or until EXITWHILE.
     strextract CurDirN DirNums "," nItem
     if not nullstr CurDirN  ; See if we're at the end of list.
     
         ;This part of the script is where the DN's are resolved as TN's.
         transmit "prt^M"
         waitfor "TYPE:"
         transmit "dnb^M"
         waitfor "CUST"
         transmit "0^M"
         waitfor "DN"
         
         strlen CurDirN Len   ; Check length of text string.
         if Len == Length_DN ; if Len is correct perform action         
         	strcat CurDirN EnterStr
         	mspause 100
         	transmit CurDirN
	 	waitfor "DATE"
	 	transmit EnterStr
	 	waitfor "PAGE"
	 	transmit EnterStr
	 	waitfor "DES"
  	 	transmit EnterStr
	 	waitfor "NACT"
	 		
	 	;capture screen display to file
	 	set capture file FName    ; Set name of capture file.
	 	set capture overwrite ON
   		capture on                 ; Open up the capture file.
	 	transmit EnterStr
	 	waitfor "REQ:" 
 	 	capture off                ; Close the capture file.
		;playback from capture file
		
		FName = "C:\Program Files\Symantec\Procomm Plus\Capture\Screen.txt"
		if isfile FName              ; Make sure file exists.
 	       	   if fopen 0 FName READ     ; Open file for read.
        	     while not feof 0       ; Loop to end of file.
        	       fgets 0 LineInfo    ; Get line from file.
        	       
        	       		;check for existance of TN in line.	
        	       		if strfind LineInfo "TN"
        	       			;TN exists in the line so extract the TN String 			
        	       			strreplace LineInfo "TN   " "STAT " ;remove TN header and replace for STAT command
               	       			substr TNStr LineInfo 0 16 ;strip it off at end of TN numbers
               	       			strcat TNStr "^M" ;add ENTER
               	       			transmit TNStr
        	       			;responds with state of TN
        	       			waitfor "REQ:"
               	        	endif
               	     endwhile
        	     fclose 0               ; Close the file.
	            endif
	         else
	              errormsg "File doesn't exist."
	         endif
         else
         	transmit "****^M"
         	waitfor ">"
         	transmit "LD 20^M"
         	waitfor "REQ:"
         endif
         nItem++               ; Increment.
     else
         exitwhile             ; If blank file name, exit loop.
     endif
     endwhile
ENDPROC

PROC ENLU_TN
        mspause 250
	strreplace TNStr "STAT" "ENLU" ;remove STAT command and replace with ENLU command
	transmit TNStr
	waitfor "REQ:"
	strreplace TNStr "ENLU" "STAT" ;swap back commands
	transmit TNStr
	waitfor "REQ:" 3
	IF FAILURE
	USERMSG "TN WAS NOT SUCCESSFULLY RE-ENABLED"
	ENDIF        
ENDPROC

PROC TERM
   ;this procedure is run as a cleanup before exiting the script
   transmit "****^M"
   statmsg "Script Problems ? > ICQ: 1903368"
   exit
ENDPROC

I hope you find this as helpful and timesaving as we all do !
 
dear Comtechau
could u pls, axplain me how to use this script , do i have to copy this and past it on procompluse desktop?
and where i can lear about script?

thanks alot

Atef

JORDAN -Amman
 
The script is only useful to you if you have PROCOMM PLUS.
Assuming that you have Procomm...
Run Procomm - From Procomm menu go to > Tools then > Script then > Compile|Edit.
Select NEW. {this opens Procomm's Script Editor}

Paste the script contents into the Pro'Plus Editor.
{use the second script version WITHOUT the login stuff}

The select File > Save As
-- Give the script a Name [DN_Enable] and save it to your Procomm Plus ASPECT Folder. At this stage it is an uncompiled script file.
{usually C:\Program Files\Symantec\Procomm Plus\Aspect}

Select Tools > Compile. {this creates the compiled script)

Close Procomm Plus Editor.

The script will now be in Procomm Plus...

Use Procomm to access your PABX as per normal. Once logged in to your Nortel pabx, the "DN_Enable" script will be listed in the script file list.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top