Welcome, Guest. Please login or register.

Author Topic: strip off binary content via perl  (Read 3127 times)

steffen1

  • Full Member
  • ***
  • Posts: 103
    • View Profile
strip off binary content via perl
« on: December 14, 2010, 03:30:08 PM »
Hello,

I'm looking for a perl example, how to strip off binary content from strings that normaly should be 100.000% ASCII.
Something like this, but as "real working":)
$if_descr =~ s/\w+\W$//;   # try to strip off Escape Characters in content

Thats because we propagate nedi content into nagios and some exotic boxes, e.g. Avocent, can contain (yes very seldom, but it happen in some environments) coincidentally binary content in interface description & aliases, names and so on, that will cause syntax errors in nagios configuration finaly if you do such things.

thx for feedback in advance

Steffen

steffen1

  • Full Member
  • ***
  • Posts: 103
    • View Profile
Re: strip off binary content via perl
« Reply #1 on: December 23, 2010, 09:48:36 AM »
finaly it is very easy: s/\xYY//, whereby YY=ASCII code of escape char to be stripped off

For now, I use this "s/\x//", because it removes any none printable char from a string

Steffen