- 论坛徽章:
- 0
|
在起SNMP接受消息的时候收到的一串消息中,前57个字节是16进制,后70个字节是10进制,现在我输出的时候前面的57个字节就成了乱码,但是后面的10进制能够正确输出,怎样能够将前面的57个字节按照16进制格式输出??
- #!/usr/bin/suidperl
- use strict;
- use IO::Handle;
- use BER;
- use Socket;
- require 'SNMP_Session.pm';
- $BER::pretty_print_timeticks = 0;
- my $trap_session = SNMPv1_Session->open_trap_session() or die "cannot open trap session";
- while(1){
- my($trap,$sender_addr,$sender_port) = $trap_session->receive_trap() or die "cannot receive trap";
- my($community, $enterprise, $agent,$generic, $specific, $sysUptime, $bindings) = $trap_session->decode_trap_request($trap) or die "cannot decode trap received";
- my $binding;
- my $oid;
- my $value;
- while ($bindings ne '') {
- ($binding,$bindings) = &decode_sequence ($bindings);
- ($oid, $value) = decode_by_template ($binding, "%O%@");
-
- my $oidname=$OidName{BER::pretty_oid($oid)};
- my $oidvalue=pretty_print ($value);
-
- print BER::pretty_oid($oid),"=",$oidvalue,"\n";
-
- }
- }
复制代码 |
|