[aklug] Re: safe output to terminal?

From: R Denison <gaijin@gci.net>
Date: Wed Oct 20 2010 - 08:45:05 AKDT

  On 10/16/2010 05:50 PM, Royce Williams wrote:
>> On Fri, Oct 15, 2010 at 8:16 PM, Christopher Howard<choward@indicium.us>wrote:
>>
>> display. Is there a filter program or something that I can run the
>> output through that would sanitize the output just enough for safe
>> viewing in the terminal?
>
> Has anyone mentioned strings(1) yet? It may not be as fast as Syz's
> program, but it's on every Unix-like I know of.
>
> Royce

-1 to Royce for the abominable vice of top posting... :-D My
recommendation?

tr -cd [:print:]

Unfortunately, I believe the character class is a Gnu-ism - it may break
in interesting ways on non-Gnu systems.

Just for the sake of completeness I did some testing; my system couldn't
produce enough useful data fast enough just reading from /dev/random so
I created a large blob from the contents of /bin and /usr/bin.

for I in /bin/* /usr/bin/*; do cat $I >> data; done

Actually dumping to STDOUT on Gnome terminal was painful, mostly because
I like the desktop "bling" (as a guess) so I dumped to everyone's
favorite output sink instead:

gaijin@obsidian:~$ time ( dd if=data bs=$((1024*1024)) count=83 | tr -cd
[:print:] > /dev/null )
83+0 records in
83+0 records out
87031808 bytes (87 MB) copied, 0.390923 s, 223 MB/s

real 0m0.394s
user 0m0.350s
sys 0m0.140s

gaijin@obsidian:~$ gcc -W -Wall -o clean clean.c
gaijin@obsidian:~$ time ( dd if=data bs=$((1024*1024)) count=83 |
./clean > /dev/null )
83+0 records in
83+0 records out
87031808 bytes (87 MB) copied, 0.572573 s, 152 MB/s

real 0m0.575s
user 0m0.510s
sys 0m0.290s

gaijin@obsidian:~$ time ( dd if=data bs=$((1024*1024)) count=83 |
strings > /dev/null )
83+0 records in
83+0 records out
87031808 bytes (87 MB) copied, 1.40904 s, 61.8 MB/s

real 0m1.412s
user 0m1.330s
sys 0m0.370s

If time weren't an issue I'd go to text console, unfortunately work
calls. Kudos to David - his program turned in a very respectable time.

If you'll all excuse me I need to go empty my bit-bucket now.

R.
---------
To unsubscribe, send email to <aklug-request@aklug.org>
with 'unsubscribe' in the message body.
Received on Wed Oct 20 08:45:23 2010

This archive was generated by hypermail 2.1.8 : Wed Oct 20 2010 - 08:45:23 AKDT