--enable-developer

Brian Candler B.Candler at pobox.com
Tue Nov 6 12:46:22 CET 2012


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...


More information about the Freeradius-Devel mailing list