Mailinglist Archive: opensuse (4053 mails)

< Previous Next >
Re: splitting a string
  • From: "S.Toms" <smotrs@xxxxxxxxxxxxxx>
  • Date: Thu, 9 Aug 2001 19:54:46 -0700 (PDT)
  • Message-id: <Pine.LNX.4.21.0108091945540.30006-100000@xxxxxxxxxxxxxxxxxxx>
On Thu, 9 Aug 2001, Jay Vollmer wrote:

jv> Try this:
jv>
jv> echo $STRING|awk -F: '{print $1}'
jv>


This is what I ended up using, should have mentioned it was bash sorry
about that everyone. :) Anyway, what I wanted to do was quickly count the
entries on a particular port in my /var/log/firewall file to see how many
attempts have been coming in, and I didn't want to install apache on my
firewall to check them for CR/CR2 so I tried the following


pipedream:~ # probechk myaddr:80

<probechk file>

#! /bin/bash

AWK="/usr/bin/awk"
GREP="/usr/bin/grep"
SORT="/usr/bin/sort"
UNIQ="/usr/bin/uniq"

ADDRESS=`$GREP "$1" /var/log/firewall | $AWK '{print $12}' | $SORT | \
$AWK -F: '{print $1}' | $UNIQ | $GREP -c -e [0-9]`

echo $ADDRESS individual machines

</probechk file>

This allows me to quickly count how many individual machines have tried
to connect to port 80 and compare it to what I'm used to which is
approximately 5-10 attempts in a week. So out of the 165+ I've gotten
since Monday, 155-160 are probably CR/CR2's.
Anyway, thanks for all the ideas I received, helps for the future when
I'm playing with other things just to see if I can do something.

jv>

--
S.Toms - smotrs@xxxxxxxxxxxxxx - www.mindspring.com/~smotrs
SuSE Linux v7.0+ - Kernel 2.2.18

On-line, adj.:
The idea that a human being should always be accessible to a
computer.


< Previous Next >
Follow Ups
References