Usage…
saved it as countMsgPatType.tcl (binary) in /home/hci
takes the filename as a parameter.
Quick and dirty… may be a better way to do it… but here it is.
#!/qdx/qdx5.3/integrator/bin/hcitcl
#
set fileName [lindex $argv 0]
# open file specified
if [catch { open $fileName r} inFile] {
puts stderr “Cannot open $fileName: $inFile”
} else {
# grab contents of file
set contents [split [read $inFile] n]
close $inFile
}
lappend reportData {“msgType” “count”}
#loop through the contents for each message.
foreach message $contents {
#initialize for each message
set evn_1 “”
set pv1_18 “”
set segments [split $message r]
foreach seg $segments {
set segId [string range $seg 0 2]
switch -exact — $segId {
MSH {
set fieldDelim [string range $seg 3 3]
set compDelim [string range $seg 4 4]
}
EVN {
set evn_1 [lindex [split $seg $fieldDelim] 1]
}
PV1 {
set pv1_18 [lindex [split $seg $fieldDelim] 18]
}
default {}
}
}
set msgTypePatType “$evn_1_$pv1_18”
if {[lsearch [keylkeys reportData] $msgTypePatType] > 0} {
set counts [keylget reportData $msgTypePatType]
incr counts
keylset reportData $msgTypePatType $counts
} else {
if { $msgTypePatType != “_” } {
keylset reportData $msgTypePatType 1
}
}
}
set keyList [keylkeys reportData]
foreach key $keyList {
echo “$key: [keylget reportData $key]”
}