[英]Trying to read DBM file
I have a stripped down real-time Linux box that interfaces with some hardware. 我有一个精简的实时Linux盒,可以与某些硬件接口。
The configuration files are *.dbm files and I cannot access them. 配置文件是* .dbm文件,我无法访问它们。 They seem to be some sort of key-value database but every library I have tried has come up empty. 它们似乎是某种键值数据库,但是我尝试过的每个库都空了。
I have tried the DBM reading libraries from Perl, Python, and Ruby with no luck. 我曾经尝试过Perl,Python和Ruby的DBM读取库,但运气不佳。 Any guidance on these files would be great, I have not seen them before. 这些文件的任何指导都很好,我之前从未见过。
This is what happens when I cat one file out. 当我将一个文件删除时,会发生这种情况。
DBMFILE Aug 31 2004,�
,jy �
�~���"��+�K&��gB��7JJ�
,��GLOBA.PB_COMBI�SMSI���
JG]
,��BUS_DP
PC �
'
xLokalT
J��
,��SL_DP
PC!�
��
#,��PLC_PARAMJPf,��PROJEKT�PROFIBUS new network1.00022.02.2012J,��KBL_HEADER:�JJp,��KBLJ��,��ALI-SETUPB ����
������������������JJ,,��OBJ-DEFJJ��,��ALI_CLIENTTJJ�
,��ALI_SERVERJ J\r�����2, �� ST_OV_00Boolean0Integer8 0Integer16
0Integer32
0Unsigned8
0Unsigned32Floating-Point0igned16
Octet String Jo� ,��DESCRIPT �ABB OyABB Drives RPBA-01ABBSlave1***reserved***�
�
%
So to show what i've tried already, and only come up with empty objects ( no key-values)*edit 因此,为了展示我已经尝试过的内容,并且只提出了空对象(没有键值)*编辑
perl - perl-
#!/usr/bin/perl -w
use strict;
use DB_File;
use GDBM_File;
my ($filename, %hash, $flags, $mode, $DB_HASH) = @ARGV;
tie %hash, 'DB_File', [$filename, $flags, $mode, $DB_HASH]
or die "Cannot open $filename: $!\n";
while ( my($key, $value) = each %hash ) {
print "$key = $value\n";
}
# these unties happen automatically at program exit
untie %hash;
which returns nothing 什么都不返回
python - python-
db = dbm.open('file', 'c')
ruby - 红宝石-
db = DBM.open('file', 666, DBM::CREATRW)
Every one of these returned empty. 这些中的每一个都返回空了。 I assume they use the same low level library. 我假设他们使用相同的低级库。 Some history/context on DBM files would be great as there seems to be some different versions. DBM文件的一些历史记录/上下文可能很棒,因为似乎存在一些不同的版本。
**Edit **编辑
running file on it returns 正在运行的文件返回
$ file abb12mb_uncontrolledsynch_ppo2_1slave.dbm
abb12mb_uncontrolledsynch_ppo2_1slave.dbm: data
and running strings outputs 和运行字符串输出
$ strings abb12mb_uncontrolledsynch_ppo2_1slave.dbm
DBMFILE
Aug 31 2004
GLOBAL
PB_COMBI
SMSI
BUS_DP
Lokal
SL_DP
PLC_PARAM
PROJEKT
PROFIBUS new network
1 .000
22.02.2012
KBL_HEADER
ALI-SETUP
OBJ-DEF
ALI_CLIENT
ALI_SERVER
ST_OV_0
Boolean
Integer8
Integer16
Integer32
Unsigned8
Unsigned16
Unsigned32
Floating-Point
Octet String
DESCRIPT
ABB Oy
ABB Drives RPBA-01
ABBSlave1
***reserved***
Just to make my comment clear, you should try using the default options for DB_File
, like this 为了使我的评论清楚,您应该尝试使用DB_File
的默认选项,例如
use strict;
use warnings;
use DB_File;
my ($filename) = @ARGV;
tie my %dbm, 'DB_File', $filename or die qq{Cannot open DBM file "$filename": $!};
print "$_\n" for keys %dbm;
From the documentation for Perl's dbmopen function : 从Perl的dbmopen函数的文档中 :
[This function has been largely superseded by the tie function.] [此功能已被tie函数取代。]
You probably want to try tie
ing it with DB_File . 您可能想要尝试tie
其与DB_File tie
。
use DB_File;
tie %hash, 'DB_File', $filename, $flags, $mode, $DB_HASH;
Then your data is in %hash
. 然后,您的数据在%hash
。
Might also be interesting to run file
against the file to see what it actually is. 也可能是有趣的运行file
对文件,看看它究竟是什么。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.