: "see_edf.ksh by Dan Martin (DRM/CTG) 04-20-2000" # Reads files like kyowc_20000323_003406.edf (OMNI-related) function _usage { cat << BOX Usage: $1 omnifile.edf [V|T] Where: "omnifile.edf" is a valid pathname to an OMNI Express type datafile ending in .edf And: V = Verbose Mode (shows some info for every record) T = Terse Mode (default) Action: Analyzes and reports stats on the file. BOX exit } # EOF _usage() function _dang { cat << BOX Program $1 terminated! $2 BOX exit } # EOF _dang() [[ -z "$1" ]] && _usage "$0" [[ -f "$1" ]] || _dang "$0" "Could not find file \"$1\"!" [[ -z "$2" ]] && way=T || way=$2 # echo "\nNow processing file \"$1\" (${way})...\c" awk -v op="$way" -v fil="$1" ' ## AWK FUNCTIONS: # spc(n) slides n [more] spaces along the current line: function spc(n) {for (i = 0; i < n; i++) printf(" ")} # str(n) prints a bar of n "stars" along the current line: function str(n) {for (i = 0; i < n; i++) printf("*")} # skip(n) jumps to the next line and skips down an additional (n-1) lines: function skip(n) {for (i = 0; i < n; i++) printf("\n")} BEGIN \ {# HEADER RECORD VARIABLES (NR == 1): ornum = "www" # Order Number (Number ??) dof = "xxx" # Date of file MMDDYYYY nrecr = "yyy" # Number of detail records (NR - 1) nrecc = 0 # Num Recs coerced to numeric fsqnr = "zzz" # File Sequence "Number" fsqnc = 0 # FSN coerced to numeric phty = "xx" # Phone Type phonr = "xxx" # Phone Ownership cuid = "xxx" # Customer ID cuid2 = "xxx" # Customer destination/suffix jnum = 1 # Junk Number if (op == "T" || op == "V" ) jnum = 0 if (jnum == 1) op = "T" # DETAIL RECORD VARIABLES (NR > 1): mlid = "xxx" # Manufacturers Location ID mfnam = "xxx" # Manufacturers name modno = "xxx" # Model Number mdnam = "xxx" # Model Name eqty = "xx" # Equipment Type lork = "xxx" # Lot# or Revision Key esn = "xxx" # Electronic Serial Number imsi = "xxx" # Intl. Mobil Station ID akey = "xxx" # Authentication Key slc1 = "xxx" # Subsidy Lock Code 1 slc2 = "xxx" # Subsidy Lock Code 2 plc = "xxx" # Phone Lock Code desn = 0 # Decimal ESN svnr = "xxx" # Software Version Number - Raw svnc = 0 # SVN coerced to numeric # ARRAYS DEFINED: # tyeq[] = Different Equipment type-counter # nammf[] = Manufacturer Names # nomad[] = Different Model Numbers # aesn[] = ESNs discovered # Print File info: printf("\n\n") printf("EDF FILE EXAMINED: \"%s\" (%s)\n\n", fil, op) } # main() {if (NR == 1) # Header Record Position: {ornum = substr($0, 1,20) # 001-020 dof = substr($0, 21, 8) # 021-028 nrecr = substr($0, 29, 6) # 029-034 nrecc = 1 * nrecr fsqnr = substr($0, 35, 6) # 035-040 fsqnc = 1 * fsqnr phty = substr($0, 41, 2) # 041-042 phonr = substr($0, 43, 4) # 043-046 cuid = substr($0, 47,12) # 047-058 cuid2 = substr($0, 59, 6) # 059-064 # resh = substr($0,176,115) # 065-179 - Reserved tds = sprintf("%2s/%2s/%4s", \ substr(dof,1,2), substr(dof,3,2), substr(dof,5,4)) # Print Header info: printf("\n") printf("ORDER NUMBER FILE DATE COUNT SEQ # ") printf("TY OWNR CUSTOMER ID DESTIN\n") printf("-------------------- ---------- ----- ----- ") printf("-- ---- ------------ ------\n") printf("%-20s %10s %5d %5d ", ornum, tds, nrecc, fsqnc) printf("%2s %4s %12s %6s\n\n", phty, phonr, cuid, cuid2) if (op == "V") {printf("OMNI MODEL NUMBER ESN \n") printf("-------------------- -----------\n") } } else {mlid = substr($0, 1, 3) # 001-003 mfnam = substr($0, 4,30) # 004-033 modno = substr($0, 34,20) # 034-053 mdnam = substr($0, 54,30) # 054-083 eqty = substr($0, 84, 2) # 084-085 lork = substr($0, 86, 5) # 086-091 esn = substr($0, 92,11) # 092-102 imsi = substr($0,103,15) # 103-117 akey = substr($0,118,26) # 118-143 slc1 = substr($0,144, 6) # 144-149 slc2 = substr($0,150, 6) # 150-155 plc = substr($0,156, 4) # 156-159 desn = substr($0,160,11) # 160-170 svnr = substr($0,171, 6) # 171-175 svnc = 1 * svnr # resd = substr($0,176, 4) # 176-179 - Reserved # Rachet the array counts: ++tyeq[eqty] ++nammf[mfnam] ++nomod[modno] ++aesn[esn] if (op == "V") printf("%-20s %-11s\n", modno, esn) } } END \ { if ((NR -1) != nrecc) {printf("WARNING! RECORD COUNT WRONG! ") printf("Header says %d but actual count is %d!\n\n", nrecc, (NR -1)) } printf("\n") # Print Detail info: for (nam in nammf) printf(" Name: %-30s Count: %4d\n", nam, nammf[nam]) for (ty in tyeq) {printf(" Type: %-2s", ty) spc(32) printf("Count: %4d\n", tyeq[ty]) } for (mod in nomod) {printf("Mod #: %-20s", mod) spc(14) printf("Count: %4d\n", nomod[mod]) } aak = 0 for (ct in aesn) {ect += aesn[ct] if (aesn[ct] > 1) {++aak; spc(7) printf("** WARNING: ESN %s HAS %d DUPLICATES! **\n", ct, aesn[ct]) } } # printf("\n") # spc(37) if (aak == 0) {printf("NO DUPLICATE ESNs FOUND!"); spc(13)} else {printf("FOUND %3d ESNs WITH DUPLICATES!", aak); spc(6)} printf("ESN-Count: %4d\n", ect) printf("\n") }' $1 # EOF see_edf.ksh