last non-DBI attempt - reading MS Access .ldb (locked db file) with Perl
From: Frank A Willis (frank.a.willis_at_lmco.com)
Date: 03/16/05
- Next message: Amonotod: "Re: last non-DBI attempt - reading MS Access .ldb (locked db file) with Perl"
- Previous message: Scott V \ Nipp: "RE: NULLs in Text::CSV_XS and DBD::CSV"
- Next in thread: Amonotod: "Re: last non-DBI attempt - reading MS Access .ldb (locked db file) with Perl"
- Maybe reply: Amonotod: "Re: last non-DBI attempt - reading MS Access .ldb (locked db file) with Perl"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Wed, 16 Mar 2005 14:47:05 -0500 To: dbi-users@perl.org
DBI users group,
I've made one last attempt at looking for a way to read and parse out an
(MS Access) .ldb (locked database) file independent of using the DBI.
One suggestion that I received today was to split the contents of my
buffer ($buf) up using the split command as follows:
------------------------------------------------------------------------
------------------------------------------------------------------------
-------------------
#!/usr/local/bin/perl -w
#this command opens the .ldb file
open(odbfile_in,"+<ANYFILE.LDB") || die("Could not open file!");
# this section contains properties of the open .odb file
my
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blks
ize,$blocks)=stat(odbfile_in);
print "\nfile size (bytes) =",$size,"\n";
sysread(odbfile_in,$buf,$size);
@first_array=split(/x00/,$buf);
@second_array=split(/x00+/,@first_array);
print @second_array;
close(odbfile_in);
The above script assumes that the .ldb file is in a hexadecimal format
as follows:
43 4F 4D 50 55 54 45 52 4E 41 4D 45 30 31 00 20 ; FIELDNAME.
20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 20 ;
55 53 45 52 4E 41 4D 45 20 20 20 30 31 00 00 00 ; FIELDVALUE 01...
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ; ................
However, if I just read the file with sysread(odbfile_in,$buf,$size);
and print the contents of the buffer using print $buf; I get the output
below:
Version:wsX.X-XXXSource File:
Filenamews>Date/Time:wsM-D-YYwsatwsHH:MM:SS(c)NextField:wsTextCount:wsIn
teger ValuewsNextField:wsText NextField:wsText
AddressField:wsHexadecimalwsCount:wsIntegerwsType: Integer ... the
sequence repeats itself not including Version, Source File, and
Date/Time fields, i.e., NextField, NextField, NextField, AddressField,
Count, Type, NextField, NextField, NextField, AddressField, Count, Type,
...
Key: ws = whitespace characters (one or more)
Bold = Field Names w/Colon (FieldName: )
(c) = Marks where the non-header part of the file starts
Is there any way to do this by just using printf, split, and other
output formatting commands or am I better off using the DBI? I'm going
to try the AnyData::Format::Paragraph module tonight and see what
success I can have with it.
Thanks for the helpful reply posts!
Frank Willis
F/A-22 Avionics Engineer
Lockheed-Martin Aeronautics Company
Building L-11, 2nd Floor, Area "F", MZ 0033
86 South Cobb Drive
Marietta, GA 30063
Phone: 770-494-9023
Fax: 770-494-5284
- Next message: Amonotod: "Re: last non-DBI attempt - reading MS Access .ldb (locked db file) with Perl"
- Previous message: Scott V \ Nipp: "RE: NULLs in Text::CSV_XS and DBD::CSV"
- Next in thread: Amonotod: "Re: last non-DBI attempt - reading MS Access .ldb (locked db file) with Perl"
- Maybe reply: Amonotod: "Re: last non-DBI attempt - reading MS Access .ldb (locked db file) with Perl"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|