Mailing List
Home
Forum Home
Linux - General Red Hat Linux discussion list
Enterprise Linux 3 - Discussion of Red Hat Enterprise Linux 3 (Taroon)
Installation - Getting started with Red Hat Linux
Red Hat Linux 9 - Discussion of Red Hat Linux 9 (Shrike)
Red Hat Linux 7.3 - Discussion of Red Hat Linux 7.3 (Valhalla)
Red Hat Linux 7.2 - Discussion of Red Hat Linux 7.2 (Enigma)
Apache Web Server
Oracle database, Microsoft SQL server ...
Subjects
application/x mplayer2 plugin
RPM error: db4 error(16) from dbenv >remove: Device or resource
   busy
Command stream end of file while reading
X Windows problem (xauth)
Upgrading openoffice 1 1 rpm
FTP: connection refused
FTP: connection refused
mount: /dev/cdrom: is not a valid block device
Dell Precision 650, RedHat 9, no sound
how to trace the cause resulting in the crash of bind server
Virus on the list
UNINSTALL RPM MYSQL
usb pen drives: mounting as a user
broadcom network interface
make mrproper
sendmail configuration on redhat
Couldn 't open PID file /var/run/named/named pid Permission denied
Promise 378 controller
kernel 2 6 and /dev/sound/mixer not found
Problem using up2date
mrtg step by step howto/configuration for a newbie?
Compiling and Installing Kernel 2 6
Can 't locate module ppp0, can 't locate module ppp compress 21
HOW I CAN MAKE BOOTABLE FLOPPY DISKET
Lotus Notes under Wine
/etc/security/limits conf question
Intel E/1000 driver
Command stream end of file while reading
rpm database corrupt
qla2300 modules
 
Search:  
Power your search with and, or, +, -, or "some phrase" operators.
script needed

script needed

2005-08-16       - By Chris St. Pierre

 Back
Reply:     1     2     3     4     5     6     7     8     9     10     >>  

Here's the command you'll need for your first question:

$ man awk

And for your second question:

$ man grep

HTH.

Chris St. Pierre
Unix Systems Administrator
Nebraska Wesleyan University

On Tue, 16 Aug 2005, kmail wrote:

>thanks to all, I tried  it but I got (1.2.3.4[1.2.3.4]) as result, how can I
>parse the ip inorder to add it to hosts.deny?
>
>also, how to ignore monitoring ip if I have them listed in a test file.
>
>thank you
>
>-- -- Original Message -- --
>From: "Michael Velez" <mikev777@(protected)>
>To: "'General Red Hat Linux discussion list'" <redhat-list@(protected)>
>Sent: Friday, August 05, 2005 4:02 PM
>Subject: RE: script needed
>
>
>>
>>
>> > -- --Original Message-- --
>> > From: redhat-list-bounces@(protected)
>> > [mailto:redhat-list-bounces@(protected)] On Behalf Of Shaw, Marco
>> > Sent: Friday, August 05, 2005 8:32 AM
>> > To: General Red Hat Linux discussion list
>> > Subject: RE: script needed
>> >
>> > > #!/bin/bash
>> > >
>> > > IPADDRLIST=`tail -50 /var/log/messages | grep "<line
>> > > pattern>" | awk '{print
>> > > $<ip addr field number>}' | sort | uniq`
>> > >
>> > > for IPADDR in $IPADDRLIST
>> > > do
>> > > IPADDRCNT=`tail -50 /var/log/messages | grep "<line
>> > > pattern>" | grep
>> > > -c $IPADDR`
>> > >
>> > > if [[ $IPADDRCNT -ge 10 ]]
>> > > then
>> > > EXISTS=`grep -c $IPADDR /etc/hosts.deny`
>> > >
>> > > if [[ $EXISTS -eq 0 ]]
>> > > then
>> > > echo $IPADDR >> /etc/hosts.deny
>> > > fi
>> > > fi
>> > > done
>> >
>> > It's a slow Friday at work... ;-)
>> >
>> > Sorry, I think I found another little problem.
>> >
>> > Here: EXISTS=`grep -c $IPADDR /etc/hosts.deny`
>> >
>> > You might grep for 10.10.10.10 in /etc/hosts.deny, which
>> > would also match possibly an existing 10.10.10.100 entry by error.
>> >
>> > I think you may have to go with changing this line to something like:
>> >
>> > EXISTS=`grep -c "^${IPADDR}$" /etc/hosts.deny`
>> >
>> > I realize your script is just supposed to be somewhat of a guide.
>> >
>> > Sorry again, for the critiques (spelling?).
>> >
>> > Marco
>>
>> Yes, my script is only supposed to point in the right direction.  I only
>> took a quick stab at it.
>>
>> That said, you are correct.  Your solution would work.  That doesn't mean
>> the script still won't need changing.
>>
>> I appreciate the critique as I wouldn't want anybody to think the script I
>> wrote was the final answer.  Just goes to the point as to how much or
>little
>> one should offer in an answer.  My fault, my oversight.
>>
>> It would be up to anybody who is putting something into operation to
>verify
>> the solution deals correctly with all eventualities, especially if the
>> solution comes from a relatively unknown entity.
>>
>> That said, since I usually respond to scripting questions, from now on,
>I'll
>> put a disclaimer mentioning the lack of rigor that goes into writing
>> something that is meant to help people think about the structure of the
>> script, as opposed to the details.
>>
>> I am glad you critiqued the script, though, as you were correct in
>pointing
>> out the oversight and as it prompted me to write the above.  I guess
>that's
>> what the entire mailing list is for.
>>
>> Thanks,
>> Michael
>>
>> --
>> redhat-list mailing list
>> unsubscribe mailto:redhat-list-request@(protected)?subject=unsubscribe
>> https://www.redhat.com/mailman/listinfo/redhat-list
>>
>> ---
>> This message has been scanned for viruses and dangerous content by
>MailScanner
>> and is believed to be clean.
>
>
>--
>redhat-list mailing list
>unsubscribe mailto:redhat-list-request@(protected)?subject=unsubscribe
>https://www.redhat.com/mailman/listinfo/redhat-list
>

--
redhat-list mailing list
unsubscribe mailto:redhat-list-request@(protected)?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/redhat-list

Earn $52 per hosting referral at Lunarpages.