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

Procomm Script For Capturing Vectors For Backup & Searching 3

Status
Not open for further replies.

TMurdach

IS-IT--Management
Apr 18, 2003
61
US
I've used a lot of information from this site to help in my daily activities, so hopefully this post will be useful to somebody here. It is very nice to have when you can't remember what you changed in a crisis, and need to set things back. It is also nice to find certain keywords or numbers in vectors, such as ADJUNCT (so you know which vectors make reference to adjunct links).

This Procomm script saves the text from your vectors into a CSV file. For this to work, you must create a file (VECT1-999.TXT) with each vector number you want to capture on a separate line (I simply have 1 through 999 so nothing gets missed). Create a folder called C:\VECTORS and keep the text file there. That is also where the vector file is saved.

I use a batch file to launch the script as well as to rename the output file (using date/time). I schedule this to run every Sunday evening.

This works in CM2, not sure about CM3.

Code:
proc main ;[COLOR=red] This script telnets to the switch, 
          ; scrapes the text for vectors 1-999
          ; or whichever line numbers are listed 
          ; in C:\VECTORS\VECT1-999.TXT.
          ; C:\VECTORS\VECT1-999.TXT is used as 
          ; a counter in this example, 
          ; but if you only want to capture 
          ; certain vectors, you can leave 
          ; them out of the TXT file. It is 
          ; required to exist for this to work.[/color red]

string sLine
string vector1
set terminal type att4410

connectmanual TELNET "xxx.xxx.xxx.xxx port 5111" 
;[COLOR=red] replace xxx's with IP address used for ASA [/color red]
while $DIALING
       yield
      endwhile
   waitfor "Login: "
   transmit "xxx" ;[COLOR=red] replace xxx with login[/color red]
   transmit "^M"
   waitfor "Password: "
   transmit "xxx" ;[COLOR=red] replace xxx with password[/color red]
   transmit "^M"
   waitfor "Terminal Type (513, 715, 4410, 4425, VT220, NTT, W2KTT, SUNT): [513] "
   transmit "4410^M"
   waitfor "^[[KCommand: "
 fopen 0 "C:\Vectors\VECT1-999.txt" READ TEXT  
 while not feof 0                              
  fgets 0 sLine 
  strtok vector1 sLine "," 1
transmit "disp vect "
pause 1
transmit vector1
pause 1
transmit "^M"
call vector1 
;[COLOR=red] This is where it begins 
; scraping the lines from each page...[/color red]
endwhile
fclose 0
endproc

proc vector1
call page1
transmit "^[OV"		;[COLOR=red]next page[/color red]
call page2
transmit "^[OV"		;[COLOR=red]next page[/color red]
call page3
endproc

proc page1
   string Line                   ; [COLOR=red]Line to write to file.[/color red]
   integer Row                   ; [COLOR=red]Current row to get.[/color red]
pause 3
   if fopen 1 "C:\VECTORS\file.csv" APPEND   
;[COLOR=red] Create file to write screen to.[/color red]
      for Row = 3 upto 3        
;[COLOR=red] Loop through each row on screen.[/color red]
         termgets Row 4 Line 75  
;[COLOR=red] Get line specified by row.[/color red]
         fputs 1 Line            
;[COLOR=red] Write line from screen to file.[/color red]
         fputs 1 "`r`r"
      endfor
      fclose 1                   
;[COLOR=red] Close file opened for create.[/color red]
   else
      errormsg "Couldn't open file!"
   endif
      if fopen 1 "C:\VECTORS\file.csv" APPEND   
      for Row = 8 upto 18        
         termgets Row 0 Line 79  
         fputs 1 Line 
         fputs 1 "`r"
      endfor
      fclose 1 
   else
      errormsg "Couldn't open file!"
   endif
endproc

proc page2
   string Line 
   integer Row 
pause 3   
      if fopen 1 "C:\VECTORS\file.csv" APPEND
      for Row = 4 upto 14        
         termgets Row 0 Line 79  
         fputs 1 Line            
         fputs 1 "`r"
      endfor
      fclose 1                   
   else
      errormsg "Couldn't open file!"
   endif
endproc

proc page3
   string Line   
   integer Row   
pause 3   
      if fopen 1 "C:\VECTORS\file.csv" APPEND   
      for Row = 4 upto 14      
         termgets Row 0 Line 79  
         fputs 1 Line  
         fputs 1 "`r"
      endfor
      fclose 1    
   else
      errormsg "Couldn't open file!"
   endif
pause 1
transmit "^[OP"
endproc
 
very nice. Have a star
 
Thank you!

I should probably mention that nearly every bit of code I used in this script was learned on this forum.
 
Nice post Tmurdach.... good to know Thank you.

I thought I would chime in... if you don't have Procomm this can also be done with ASA.
I've somewhat mentioned this method in other posts...
Here's how:

1.) Using ASA, export the vectors numbers in your PBX either by using the export data function (vector) or report function(list vector)both are in the advanced section of ASA. Export them delimited so you can easily copy the vector numbers.

2.) Using notepad and or excel format the vectors numbers to the following string format: disp vec 1;disp vec 2;disp vec 3;disp vec 4;etc, etc etc... When done copy this string using edit copy or Ctrl C.

3.) In ASA's advance section Click on Reports (file menu System, Advanced, Report) In the reports window that comes up paste the string that you copied in step 2,

4.) Decide how you want to export the data.. export screen capture to file or export fields to file. Pick your path and or delimiters if you picked export fields. You can also pick to append to the existing file etc... Click OK, then decide how often you want the report to run in the scheduling section.

5.) The report is saved on the Schedule tab at the bottom of ASA, you can always add items or change the schedule by right clicking on the report. You could also mix and match your commands such as...

disp vec 1;disp hu 1;disp vdn 1;list bcms skill 1; etc....

I've used this method extensively. Bascially I have an extra PC that just runs ASA all of the time. I remote desktop into this ASA PC. I use it to export BCMS reports in case a CMS link goes down, export nightly vector data, export extension lists to many different sites automatically etc...

I mostly record the data at night, saving to folders by day of the week. Then on Sunday night/morning using the windows scheduler I run a xcopy batch file to archive the weeks data into a different folder. The reports then overwrite the previous weeks data as it goes through the days of the week. So at any point I can look at last weeks data... Plus, since it is on a network drive I could always request a restore if I needed something further back.

Thanks,

Wildcard



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top