Nmap Development mailing list archives

Re: [Patch] KRAD Ascii Art (A short and sweet patch)


From: Jacek Wielemborek <d33tah () gmail com>
Date: Wed, 19 Mar 2014 19:24:45 +0100

19/03/2014 23:31:46 Jay Bosamiya <jaybosamiya () gmail com>:
    cat $(ls docs/leet-nmap-ascii-art*.txt 2>/dev/null | awk
    'BEGIN{srand();}{lines[++d]=$0}END{print
    lines[int(rand()*49139)%d+1]}') 2>/dev/null

It seems to work quite well then. (the 49139 is a prime number not close 
to a power of 2)

Okay, now it seriously begs for being broken down into a few instructions. How 
about something like:

# print a random ASCII art in a way that works on non-GNU systems as well.
FILENAME=`ls docs/leet-nmap-ascii-art*.txt 2>/dev/null | awk '
    BEGIN {
        srand();
    }

    {
        lines[++d] = $0
    }

    END {
        # This is supposed to make AWKs random numbers more random
        print lines[int(rand()*49139)%d+1];
    }
    '`
cat $FILENAME

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
Sent through the dev mailing list
http://nmap.org/mailman/listinfo/dev
Archived at http://seclists.org/nmap-dev/

Current thread: