6 Nov
2012
6 Nov
'12
6:46 a.m.
On Mon, Nov 05, 2012 at 03:06:26PM +0000, Arran Cudbard-Bell wrote:
In Ruby:
echo "foo\200bar" | ruby -e 'puts eval("\""+$stdin.read+"\"").unpack("H*").first'
Or without eval:
echo "foo\200bar" | ruby -e 'puts $stdin.read.gsub(/\\(\d\d\d)/) { $1.to_i(8).chr }.unpack("H*").first'
I guess that works if you have arbitrary amounts of memory :)
How big are your DHCP attributes then? :) OK: echo "foo\200bar" | ruby -e 'while d=$stdin.read(32); puts d.gsub(/\\(\d\d\d)/) { $1.to_i(8).chr }.unpack("H*").first; end' Still a one-liner, as long as your console is at least 104 characters wide...