Nmap Development mailing list archives

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


From: Jay <jaybosamiya () gmail com>
Date: Thu, 20 Mar 2014 01:00:06 +0530

On Wednesday 19 March 2014 11:54 PM, Jacek Wielemborek wrote:

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
Jacek,

That does make sense... I did that and put an if at the end to prevent it from messing up if there is no such file. (And I rewrote the comments -- just personal opinion that saying that it "makes it more random" than "supposed to make it more random" seems more like a definitive statement where we know what we are doing :-) )

Seems to look nice and work well now.

   # Randomly store the name of one of the ASCII Art files in FILENAME
   FILENAME=`ls docs/leet-nmap-ascii-art*.txt 2>/dev/null | awk '
        BEGIN {
            srand();
        }

        {
            lines[++d] = $0
        }

        END {
            # This makes AWKs random numbers more random
            print lines[int(rand()*49139)%d+1];
        }
        '`
   # Print the file to screen, if any such file exists (i.e. $FILENAME
   is not empty)
   if test $FILENAME; then
        cat $FILENAME
   fi

Changed the patch file again. [1]

Should be no problem at all now.

Cheers,
Jay

[1] https://gist.github.com/jaybosamiya/e2cecc305b4055cb7776

Attachment: leetascii.patch.txt
Description:

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

Current thread: