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

Index recreation problem

Status
Not open for further replies.

dickiebird

Programmer
Feb 14, 2002
758
GB
I have a corrupt index file I'm attempting to fwrite out to a flat file, to recreate the index later.
So far so good, I fwrite out several thousands of records, then get to a point in the faulty
index where the data is not as per the 20 bytes of each record. (There's binary content in all records too)
As I'm freading 20 bytes each time, the next record is mis-aligned, as are all others.
e.g

.xPEäù cAS94 )ÿÿÿÿ
.xPEäùs cUL43 )ÿÿÿÿ
) )ÿÿÿÿ ÿÿÿÿ/÷æ äiù < this example has 24 bytes
.xPFäùs cUL43 )ÿÿÿÿ
.xMFäùs c313090)ÿÿÿÿ
)ÿÿÿÿ/÷æ äiù ÿÿÿÿ/÷æÿÿÿÿ/÷æ+++ < this example has 32 bytes

The only consistent factor in valid records are the AlphaNumeric codes in positions 11 to 16 ( always minimum 4 chars A-Z or 0-9 and spaces. Max size is 6 chars )
Anybody able to show me how to only get 'valid' records?
Perhaps by finding 4 chars in a row (in A-Z, ,0-9), seeking back 10 chars and freading 20
bytes ??
Thanks in advance
;-) Dickie Bird
Honi soit qui mal y pense
 
do you need the binary part of records ?
which os are you using: unix NT ...? -----------
when they don't ask you anymore, where they are come from, and they don't tell you anymore, where they go ... you'r getting older !
 
Hi
I'm on AIX4.3.3 - the files are legacy system and have binary content that I do need - I will translate this later to legible text.
It's the variable length (8,16,24,32 -> 80+ bytes) of (probably) index control information, that I don't need.
The records that look like .xPEäùs cBB99...) are the ones I'm interested in.
One more thing - there's no record separators at all. The file is one continuous 70mb line (so, no chance with AWK !?).
TIA
;-)
Dickie Bird
Honi soit qui mal y pense
 
my os is solaris
if using /bin/strings and,or /bin/od i get usefull infos
i would look for sources of this bin's and adapt them to
my needs. -----------
when they don't ask you anymore, where they are come from, and they don't tell you anymore, where they go ... you'r getting older !
 
Thanks J.
I used the following, with some success :
strings -6 xah|awk '/[A-Z][0-9]/ {print}'
This found my agent codes AS94, UL43 etc.
Unfortunately, I also need the previous 10 bytes
before each displayed string.
Any thoughts ???
P.S. Lowercase and spurious chars ( like c , ; : l )
appeared e.g cUL43 and ;AS48
Is my AWK incorrect.
NB I originally found the problems in the file using od
Thanks in advance. Dickie Bird
Honi soit qui mal y pense
 
if your /bin/strings support -t opt
you can generate a list of start-points
then calculate your new start, pass the list
to 'c', using lseek()
-----------
when they don't ask you anymore, where they are come from, and they don't tell you anymore, where they go ... you'r getting older !
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top