Comments (1)
That's the default Ruby string representation for the hex values. If you want to print it in the same format as your input, you need to do something like this:
"\a\xE4\n\x0E\x12\t!\x00+\x00\x00".b.unpack("C*").map { |c| "%02x" % c }.join(" ")
=> "07 e4 0a 0e 12 09 21 00 2b 00 00"
You could even add a custom formatting method, if you'd like.
require 'snmp'
module SNMP
class OctetString
def to_hex_s
self.unpack("C*").map { |c| "%02x" % c }.join(" ")
end
end
end
s = SNMP::OctetString.new("\x07\xe4\x0a\x0e\x12\x09\x21\x00\x2b\x00\x00")
s.to_hex_s
=> "07 e4 0a 0e 12 09 21 00 2b 00 00"
from ruby-snmp.
Related Issues (20)
- Ruby 2.2 Comparison Operator Deprecation Warning HOT 1
- get_bulk with non_repeaters greater than 18 HOT 1
- Support for AgentX HOT 1
- Ability to access name? HOT 2
- OIDs are incorrect after SNMP:MIB.load_module a private.enterprises mib-file
- libsmi-0.4.6 or greater required HOT 1
- Patch to add IpAddressV6 to varbind HOT 1
- Encoding::CompatibilityError: incompatible encodings: ASCII-8BIT and UTF-8 HOT 2
- Wrong matching of vendor MIBs
- Can't get symbolic name of enterprise OID in SNMPv1 trap handler
- Changing the TTL value HOT 2
- LLDP discover HOT 1
- Comparing with SNMP::Integer is inconsistent and might produce an error HOT 1
- by_name merge problem, value changed to nil HOT 1
- Suggestion to make Manager load_module consistent with MIB load_module HOT 1
- Request to support `disableAuthorization yes` HOT 4
- Pushing varbind returns from .walk to array sets value to null (SNMP::Null) HOT 1
- walk returns nothing if the oid is a leaf node HOT 5
- Infinite loop on no such name error
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ruby-snmp.