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!

Extracting Specific info From capture file to another capture file.

Status
Not open for further replies.

dmelle

Technical User
Jan 26, 2002
14
US
All,

I am trying to extract specific lines of info from a capture file that My script is capturing. The equipment outputs about two pages of data and I only need a couple of lines of it. Here is an example of the output and the lines that I need:



]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
]]]]]]]]]]]] ]]]] ]]] ]]] ]]]]]]]] ]]] ]]]]
]]]]]]]]]]] ]]]]]]]]]]]] ]]] ]]]]]]]]]]] ] ]]]]]]] ]]] ] ]]]]
]]]]]]]]]] ]]]]]]]]]]]] ]]] ]]]]]]]]]]] ]] ]]]]]] ]]] ]] ]]]]
]]]]]]]]] ]]]]]]]]]]]] ]]] ]]]]]]]]]]] ]]] ]]]]] ]]] ]]] ]]]]
]]]]]]]] ]]]]]]]]]]]] ]]] ]]]]]]] ]]]] ]]]] ]]] ]]]]
]]]]]]] ]]]]]]]]]]]] ]]] ]]]]]]]]]]] ]]]]] ]]] ]]] ]]]]] ]]]]
]]]]]] ]]]]]]]]]]]] ]]] ]]]]]]]]]]] ]]]]]] ]] ]]] ]]]]]] ]]]]
]]]]] ]]]]]]]]]]]] ]]] ]]]]]]]]]]] ]]]]]]] ]]] ]]]]]]] ]]]]
]]]] ]]] ]]] ]]] ]]]]]]]] ]]] ]]]]]]]] ]]]]
]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]


Core Director (TM) Craft Interface...


Copyright (c) CIENA Corporation, 2001.


NOTICE: Unauthorized access or use of this system will lead to prosecution.



Core Director CLI Login

UserId:
Password:

---- C I E N A C O R E D I R E C T O R ----
---- C M C L I M E N U ----
--------------------------------------------------------------
---- 1. Display current install settings
---- 2. Display general information about this CM
---- 3. Go to TL-1 CLI
---- 4. Enter Upgrade mode
---- 5. Enter Backup and Restore mode
---- 6. Change CLI Login User Id
---- 7. Change CLI Login Password
---- 8. Reset Timing Plane
---- 9. Reset Other CM
---- 10. Logout
--------------------------------------------------------------
Enter Choice (? for help anytime): 11

Invalid choice!


---- C I E N A C O R E D I R E C T O R ----
---- C M C L I M E N U ----
--------------------------------------------------------------
---- 1. Display current install settings
---- 2. Display general information about this CM
---- 3. Go to TL-1 CLI
---- 4. Enter Upgrade mode
---- 5. Enter Backup and Restore mode
---- 6. Change CLI Login User Id
---- 7. Change CLI Login Password
---- 8. Reset Timing Plane
---- 9. Reset Other CM
---- 10. Logout
--------------------------------------------------------------
Enter Choice (? for help anytime): 1
CMName .........................................SMYRGAFEH00
CoreDirector's Main Management IP address.............xxx.xxx.xxx.xxx
CoreDirector's Main Management IP address netmask.....255.255.255.0
CoreDirector's Internal Network Base address..........10.200
A-CM's Main IP address................................xxx.xxx.xxx.xxx
A-CM's Main IP address netmask........................xxx.xxx.xxx.xxx
C-CM's Main IP address................................xxx.xxx.xxx.xxx
C-CM's Main IP address netmask........................255.255.255.0
OSAgent's IP Address..................................unknown
CoreDirector IP gateway address.......................xxx.xxx.xxx.xxx
CoreDirector Auxiliary Management IP address..........unknown
CoreDirector Auxiliary Management IP address netmask..unknown
A-CM's Auxiliary IP address...........................unknown
A-CM's Auxiliary IP address netmask...................unknown
C-CM's Auxiliary IP address...........................unknown
C-CM's Auxiliary IP Address netmask...................unknown
OSRP Node Address.....................................45.000000010001000100010104.00000000ffff.00
CoreDirector CORBA BOA Main Port Number...............unknown
CoreDirector CORBA BOA Auxiliary Port Number..........unknown
CoreDirector TLI Module Port Number...................unknown
CoreDirector HTTP Port Number.........................unknown
CoreDirector Echo Port Number.........................unknown
DPFI Fault Isolation Disable..........................unknown
Current System time: .................................08/16/2002 16:47:31


---- C I E N A C O R E D I R E C T O R ----
---- C M C L I M E N U ----
--------------------------------------------------------------
---- 1. Display current install settings
---- 2. Display general information about this CM
---- 3. Go to TL-1 CLI
---- 4. Enter Upgrade mode
---- 5. Enter Backup and Restore mode
---- 6. Change CLI Login User Id
---- 7. Change CLI Login Password
---- 8. Reset Timing Plane
---- 9. Reset Other CM
---- 10. Logout
--------------------------------------------------------------
Enter Choice (? for help anytime): 2

Current Role..........................Primary
Current CM Instance...................CM0
Current Software Version..............2.0.4.cn88563
Current Software build timestamp......02/07/2002 03:23:35
Current Software build name...........R2.0_88563-2.0.4_txn
Current Software change number........88563
Current time stamp on this CM ........08/16/2002 16:47:32
Available memory on this CM ..........78307696 / 239870400 = %32

Memory usage per block size. Format: Size/#Reserved/#InUse; ... :
8/0/0; 16/0/0; 32/36806/698421; 64/87252/610075; 128/42252/109792;
256/466/4136; 512/573/2881; 1024/209/2350; 2048/55/6983; 4096/123/2275;
8192/260/1736; 16384/9/95; 32768/3/31





The only two lines that I need are the ones that start out with :

CMName .........................................SMYRGAFEH00

Available memory on this CM ..........78307696 / 239870400 = %32

This is the info that gets pulled off of each node (total 29 Nodes) so the capture file gets pretty bulky. I need the two lines mentioned above from each node. If anyone can help me I would greatly appriciate it.

Thanks,
David Melle
 
I'm assuming that the data is being saved OK to the capture file. If so, the following script should get you started:

proc main
string sInput, sName, sMem

fopen 0 "capture.txt" READ TEXT
while not feof 0
fgets 0 sInput
if strfind sInput "CMName"
strtok sName sInput "." 2
endif
if strfind sInput "Available memory"
strtok sMem sInput "%" 2
endif
endwhile
fclose 0
endproc

This script will read the file capture.txt from your ASPECT directory (so you'll need to modify this statement) line by line, searching each line for the beginning of the two lines you are interested in. If one of those lines is found, then the strtok command is used to parse out the information you are looking for. I'm not certain I got the right information for the available memory, but it shouldn't be hard to redo the logic of the strtok command in the second if strfind statement.

The only possible problem is that I've only tested the script with one occurrence of the data while it sounds like you are saving the data from all nodes into one capture file. I think this script should still work in your case, but just wanted you to be aware of this.
aspect@aspectscripting.com
 
Hello,

This should Extract your Required Data from the Capture File and Place it in a Node_Data File. Let us know if you need any more Help.

Hank

Proc Main

string sLine

fopen 0 "C:\Files\Capture.txt" Read Text ; Source File
fopen 1 "C:\Files\Node_Data.txt" Create Text ; Destination File
while not feof 0
fgets 0 sLine
if strfind sLine "CMName"
fputs 1 sLine
endif
if strfind sLine "Available memory"
fputs 1 sLine
endif
endwhile
fclose 0
fclose 1
endproc
 
Thanks guys!!! Worked like a charm. You guys are great. Ask and ye shall recieve.......
 
This looks like what I need to do as well. I am not sure were in the string you define what text to remove to 2nd capture file? Also can I run this inside the script I am already running to capture the 1st file?
 
Hello,

In my example, Strfind looks for any Occurance in the sLine. It then Copies that Line of Data to a Destination File. Of course you could Modify the Script to Extract only Particular Data from the sLine that is Matched. In this Case you could use the Strtok Function to acomplish this Task.

Also the Source File Must be a Closed File Before you can do this. So your Script would have to Capture your Data and then use my Example Script maybe as a Procedure.

If you need an Example of Strtok for my above Example let me know.

Hank

 
Hank

The following is the script I made, What do you think of it? The first part under Main Proc works great. Now I need to pull off these 4 lines and put in wbfc.txt file. It needs to overwrite the file each time. Tx for help I am new at Procomm so have to feel my way along...

proc main
when $CARRIER call check_carrier
while 1
yield
endwhile
endproc
proc check_carrier
set capture overwrite on
capture on
if $CARRIER == 0
capture off
endif
endproc

Proc StartProcess
string sLine

fopen 0 "C:\Program files\Symantec\Procomm Plus\Capture\wbfc.txt.cap" Read Text ; Source File
set capture overwrite on
fopen 1 "C:\Program files\Symantec\Procomm Plus\Capture\wbfc.txt" Create Text ; Destination File
while not feof 0
fgets 0 sLine
if strfind sLine "Final Type:"
fputs 1 sLine
endif
if strfind sLine "Fire Box:"
fputs 1 sLine
endif
if strfind sLine "Loc:"
fputs 1 sLine
endif
if strfind sLine "AKA:"
fputs 1 sLine
endif
endwhile
fclose 0
fclose 1
endproc
 
Hank

I did compile as I wrote it and it compiled ok but does not work.
 
No Problem. You can use the Delfile Function to Delete the Older WBFC.TXT file. You'll need to Check if the File Exists and Then Delete it.

If you Post a Example of your Capture File, and NOTE which Field You Need, I'll write you a Proto-type to Play with.

Looks Good so Far.

Hank
 
Hank
I did leave you a copy of it a few messages back...

Tx


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top