I have a log file as shown below. Each line starts with instance nr.
What I need to have is a script which will look up "not in the User Database" phrase at each line and when the criteria matches, the script will go five lines above (from 367th instance to 362nd instance for this log file) and grab the IP.
You could try something like:
I tested this using the Korn shell, but it should work with any POSIX-conforming shell. If you want to try this on a Solaris/SunOS system, replace awk on the 3rd line in this script with /usr/xpg4/bin/awk, /usr/xpg6/bin/awk, or nawk.
With your sample input, this produces the output:
which matches what you requested except that there is always one space between output fields (where your sample output had two spaces in the first line and one space in the second line) and there are no trailing spaces (where your sample output had one trailing space on the first line and no trailing spaces on the second output line).
This User Gave Thanks to Don Cragun For This Post:
Hello,
Many thanks for you all.
Now, I am able to extract ip addresses that should be banned.
My question is how I can communicate iplist file with fail2ban
At first I added below line into crontab:
my iplist.sh file with chmod 755 under /var/bin is :
My daemon.log file is like this:
Then I added below explanation into fail2ban:
The next step is I created a file named darwin.conf :
Could you please let me know what I should type instead of failregex = .* <HOST> in related file?
When I stop/start fail2ban, I can not see banned ip addresses under /var/log/fail2ban file.
Thanks in advance
Boris
Last edited by Scrutinizer; 10-20-2013 at 03:10 AM..
Reason: Additional code tags
What file with which structure is used where to what purpose?
Hello,
I did not want you to do all the details. I did not want to make you busy with all details. For that reason I asked you a couple of question on where I could not have found the solution.
Operating system linux and there is a software which creates its own log file. I shared the log file sample in my first message body. The main aim is to send all IP addresses which are not found in database to fail2ban.
I am sorry as I did not explain it well in my first message.
Being a beginner in scripting I am not sure the direction to take to accomplish the below task and would love suggestions.
GOAL
input file: domains.list
Read input file, search in named.conf and find domain and delete entry for the purpose of cleanup activity.
named.conf entry example
zone... (8 Replies)
picked up a 9111-520 p5 hardware recently with 8 Gig of RAM, lots of internal disk space...6 x 140 gig
had 7.1 pre-installed, and managed to upgrade the firmware to latest SF240_xxxx
goal is to virtualize this and have LPARs running aix 7.1, 6.x, and Rhat for ppc ..
need some... (13 Replies)
Okay, so I'm not a complete newb when it comes to using Unix/Linux. I've been using Ubuntu for a few years now and I've dipped my toes into a few other distros but now I want to get a bit serious.
I'm looking at becoming a sysadmin but the trouble is...I have no idea where to start. What I'm... (1 Reply)
Hey , I have become pretty normal, using unix and what not and working around FEDORA 9
I was wondering does anyone have any IDEAS or have anything I should try to build or scripts to write ,
or possibly know any sites where I could practice some things just so I know I am writing them... (2 Replies)
Hi,
I'm writing my first daemon application. I need to make sure I cover my bases as far as correct procedures, etc... I've tried to do my own legwork by reading as much as I could on daemonizing programs, etc... There are so many different examples, some include this but not that, etc...... (3 Replies)
Say I have a single bin directory with Linux and SunOS executables, like this:
bin/myprog_lnx
bin/myprog_sun
Assume these programs read from stdin and write to stdout and, thus, are meant to be run like this:
myprog_lnx < filein > fileout
My users may log in from a Linux or Solaris... (3 Replies)
I'm a senior in high school trying to start getting into computer programming. All I've done so far is picked up a book on C for beginners and started to teach myself. There aren't really any courses at my high school for introductory programming, so it looks like I'll have to wait for college to... (7 Replies)
First, I just rebuilt/installed my custom kernel & I don't know how to check if it ran properly (I'm fairly sure it did, but I'm looking for reassurance that it loaded the new kernel file).
Second, I'd love to get into programming, scripting, whatever, I want my imagination to be the builder &... (2 Replies)