Programming :: Script For Searching Through Messages For Multiple FTP Hits

Oct 25, 2010

My script looks really crap and messy, the logic isn't great and I'm not hugely happy with it. Also it echo's $i instead of an actual IP address (line 10). How to improve this. It basically searches through /var/log/messages for multiple FTP hits and when the hit count is higher than a specific number the IP is added to a config file and ftp is restarted. There are some obvious flaws in my script.

Code:
MAXHITS=0
TOPHITS=`grep "FTP session closed." /var/log/messages* | awk '{print $7}' | sed -e 's/^.*[//' -e 's/].*$//' | uniq -c | sort -nr`
HITNUMB=`echo $TOPHITS | awk '{print $1}'`
IPHIT=`echo $TOPHITS | awk '{print$2}'`
HIGHIP=`echo $TOPHITS | grep $HITNUMB | grep $IPHIT | awk '{print $2}'`

if [ $HITNUMB -gt $MAXHITS ]; then
for i in $HIGHIP;
do
echo $i
sed -i '78s/$/,$i/' /opt/etc/proftpd.conf
/root/ftp restart
done
else
echo "not greater than $MAXHITS"
fi

I'm not even sure what will happen if I get multiple responses for my $TOPHITS. It would be cool if it could search for IP's already blacklisted somehow, it might actually be easier to just create a file with a set of blacklisted IP's or something.

View 14 Replies


ADVERTISEMENT

Programming :: Script To Search And Count Hits From Some Country

Mar 25, 2011

I need something to make a script that will search some logs and extract IP hits from one country only. Let's say UK. I guess I need to use GeoIP or some database. I just need a very simple bash, perl, php script that will do this job. Just search threw logs (apache) and then give me number of hits found from UK.

View 5 Replies View Related

Programming :: Logging Messages From Program Doesn't Reach /var/log/messages?

Jul 13, 2011

I have a syslog-ng running and kernel build of 2.6.34.8 I use a syslog API in my program with facility LOG_LOCAL5 and and levels debug err and crit and info. when I ran on the older syslog facility I had everything logged fine as I intended. now I have written these rules into the syslog-ng.conf:

options {
flush_lines (0);
time_reopen (10);
log_fifo_size (1000);

[code]....

the last two rules show my program gnssapp. the result is all debug levels or crit or err levels I don't see any of them !

View 3 Replies View Related

Server :: AutoFS5 LDAP - Searching Multiple DNs

Jan 28, 2011

If there is a way in autofs5 to search for a key in multiple OU's? I am migrating our existing NIS infrastructure to LDAP. Over the years the NIS environment has evolved (not necessarily for the better). I have a back end database and each NIS master extracts specific elements from the DB to create the NIS maps.

On my Linux servers I use a program map that prgramatically searches multiple NIS maps. On Solaris I have an auto.home file that will search auto_home and auto_service ( Home has all home directories associated with people (i.e., in the passwd file) auto_service contain directories that are accessed as /home/.... but are not tied to a user account.

I also have regional data and unfortunately, my back end storage is not consistant so /apps/perl in one region will resolve to regionA:/path1/path2/perl and in another region it may resolve to regionB:/path33/path2/perl. Can this be done?

View 4 Replies View Related

Programming :: Searching For Video Or Screen Cast Which Shows Device Driver Programming?

May 30, 2010

I did searched you tube but my results were not great.I have 2 books on KernelProgramming.I feel I need if some where I can get a video tutorial which can help me to understand how to develop a Linux Device driver that will be great.I had a look at Greg Kroah Hartmans video lecture of developing patches on ......I have been reading books and a lot of stuff.So I wish if I could get a video lecture that would be better

View 1 Replies View Related

Red Hat / Fedora :: See Dmesg And /ver/log/messages Of Multiple Servers?

Oct 18, 2010

I have around 10 Servers.How to see Dmesg and /ver/log/messages of multiple servers from a centralized location

View 5 Replies View Related

Programming :: Searching And Deleting Using Sed?

Jan 7, 2010

im working on a mini project which basically use a simple database(Database.txt) which displays its information in this format :apple chiku banana

Code:
#!/bin/bash
Title=

[code]....

View 9 Replies View Related

Programming :: Searching File In Directories?

Feb 23, 2011

I am trying to search particular directory which has files with extensions like .html,.mp3,.xml etc I have a list of such files

What I am doing in my script is

for file_name in `find /home/ -name index.html -o -name song.mp3 -o -name help.xml`;
do
if [ $file!='' ]
then

[Code].....

View 4 Replies View Related

Programming :: Searching The Files Using Variables?

May 18, 2011

I have a file that contains 5 fields and anothen one with two I want to take the value from user and search file1 and if the value exists then write in file2 to the $2 to the line that $1=value

file 1
1:fsdfsd:g:33:fsdf
2:yytgdcf:a:3:sgd

[code]....

View 2 Replies View Related

Ubuntu Installation :: Will Not Boot, , Multiple Error Messages Showed Up?

Jan 2, 2011

I installed ubuntu with the windows installer. while installing in windows, multiple error messages showed up, but installation still proceeded.it rebooted, and ubuntu finished installation.on the next reboot,when i chose ubuntu from the windows boot manager, it loaded grub.however,there was no option for booting ubuntu in grub, and you are forced to go back to the windows boot manager.

View 2 Replies View Related

Programming :: Bash Function For Searching Files ?

Jun 15, 2011

I'm making a small script for searching and doing some operations with photos, but I'm kinda stuck on this little function:

Code:

function findallformat {
prefix=""
if [ $1 = -pre ] then

[code]....

That function should find for every file with a certain type; and you can specify a prefix using a "-pre" followed by the prefix that you want to search. The format should be "stackable", so you can use as many types that you want, without repeating the same function on the code.

Example: findallformat -pre IMG_ .JPG .CR2 #That should search files that start with "IMG_" and finishes with .JPG and .CR2. My problem it's that, when I try to use it on the script, it says "bash: syntax error near `token' unexpected `}'"

View 4 Replies View Related

Programming :: Grep Searching For Strings With (apostrophe)

Nov 10, 2010

I am trying a search for a pattern in the file. I can have any character in the pattern. I am pretty sure I will have $, ", ', ^, ` etc., The Problem I am facing is if I use "" (double quotes) to enclose the pattern, it gives special meaning to $, ^ and " within the string. I have no control over the pattern input. I am getting it from some other file. On the other hand, If I use '' (single quotes) to enclose the pattern, it gives special meaning to the ' (apostrophe) within the string and terminates the pattern prematurely. How do I disable the special meaning these characters have? For example, in perl, I could enclose the pattern within Q and E. Is there an equivalent in grep pattern expression? I could find one in the man page of grep. Is there a solution to this problem?

View 5 Replies View Related

Programming :: Searching For Tutorials Bout Could Never Figure Out MVC

Aug 3, 2010

I tried searching for tutorials bout could never figure out MVC.

View 13 Replies View Related

Programming :: Searching Recursively By Exif Date?

Feb 20, 2010

I have searched diligently but can't seem to find a way to search by exif date. Most of my searches turned up commands to manipulate EXIF data not just search by it. I have found some likely tools but suspect that I don't know enough bash to recursively find a .jpg file by it's exif date. For example, exiprobe and exifgrep look promising (see examples below).

I have made some progress. At first, I couldn't associate the file name with the date given but learned that the "n" option forces each output line to start with the file name. Now, I need to make the command recurse but can't seem to manage it.
halloween_IMG_0965.JPG: JPEG.APP1.Ifd0.Exif.DateTimeOriginal = '2009:10:31 20:58:52
If it helps, I have linked to the man pages [URL]

View 6 Replies View Related

Programming :: Bash - Searching Strings For Array Elements?

Apr 30, 2010

...and returning the index of the found element in its array.

I have:

for ((i=0; i < ${#array1[@]}; i++)); do
# Read each line of the file test
if [[ $(eval "sed -n '$(($i+1))'p test") == *${array2[0]}* ]]
stuff

I want to find the index of the found substring in array2 and only if it isn't found, move on to the next element of array2. I don't know the size of array2 so that [0] has just got to go.

View 14 Replies View Related

Programming :: Searching Pattern In Tab Delimited File Using Grep

Mar 4, 2010

Suppose i have a file(1.txt) separated by TAB delimiter in a line

1 B AB 2
2 C AB 2

if I need to search for the records having B?? using grep.If i need to perform multiple search like line having "C and AB" or "B and AB"??

View 5 Replies View Related

Programming :: Searching Thunderbird Emails & Extracting Information

Jun 8, 2010

I have a load of emails in my Thunderbird trash folder and some of them (all with a similar subject) I want to extract the email address for them and put in a text file. I have located the trash file but it seems that it is just a big flat file with a concatenation of all my emails in it, varying number of header lines etc etc - ie, something which really doesn't seem to suit awk, sed, grep etc.Does anyone know of any way this might be accomplished, or any third party tools which may help?

View 1 Replies View Related

Programming :: Shell Script Searching File In A Directory?

Feb 23, 2011

I am trying to search particular directory which has files with extensions like .html,.mp3,.xml etc I have a list of such files What I am doing in my script is

for file_name in `find /home/ -name index.html -o -name song.mp3 -o -name help.xml`;
do
if [ $file!='' ]
then

[code]....

I have around 100+ files name with some particular extension , this code works fine if the directory name does not have any special character in it like " "(white character) .

It is failing to give the output. IF I run the find command on the console the I am getting the correct file name with location

/home/user1/public_html/mediawiki/config/movie.mp3
/home/user1/public_html/mediawiki/movie.mp3
/home/user1/public_html/mediawiki/pop.mp3
/home/user2/public_html/index test/pop.mp3
/home/user2/public_html/index test/web.xml
/home/user2/public_html/song.mp3

If I echo the file name from the script Then output is little missed match when a directory name has special char like " "

/home/user1/public_html/mediawiki/config/movie.mp3
/home/user1/public_html/mediawiki/movie.mp3
/home/user1/public_html/mediawiki/pop.mp3

[code]....

I am not sure what is wrong with script or my code .. Does shell have un-controlled behavior of manipulating the output of any command.

View 14 Replies View Related

Debian Programming :: Searching For A List Of Strings In File With Python

Oct 14, 2013

I'm trying to search for several strings, which I have in a .txt file line by line, on another file.

So the idea is, take input.txt and search for each line in that file in another file, let's call it rules.txt.

So far, I've been able to do this, to search for individual strings:

Code: Select allimport re

shakes = open("output.csv", "r")

for line in shakes:
    if re.match("STRING", line):
        print line,

How can I change this to input the strings to be searched from another file?

So far I haven't been able to.

View 3 Replies View Related

Programming :: Sed Script - Searching For Text Within File / Replace With Variable

Feb 25, 2011

Code:
#!/bin/bash
VARR=`cat /proc/asound/cards | grep HDMI | cut -c 1-2`
VARX="defaults.ctl.card $VARR"
VARY="defaults.pcm.card $VARR"
FILE1="alsa"
FILE2="alsa.new"
echo $VARX
echo $VARY
sed "s/defaults.ctl.card*/'$VARX'/g" $FILE1 > $FILE2

This is what I have right now. Well, I thought I knew sed, and apparently I don't... I tried writing this for someone else, and this has given me trouble, so since the user pretty much figured it out on his own, here it goes.
Say VARR=1, so VARX and VARY contain the above text, appended by 1.
What I am trying to do is replace the text "defaults.ctl.card 0" by VARX and "defaults.pcm.card 0" by VARY. The contents of FILE1 is the file being used to search for both text fields, and FILE2 is the output file. I tried using single quotes, double quotes, and a mixture of both, and no go whatsoever. So my question... What is the proper way of searching for text within a file and replacing with a variable?

View 5 Replies View Related

Ubuntu Installation :: Shows Multiple CPU Overtemp Messages And Freezes With Totally Black Screen

Jan 20, 2010

I burnt the Ubuntu 9.10 ISO to CD and installed on a freshly nuked Dell 2350. It is pentium 4 at 1.8 MHZ with 512 RAM. Just a spare machine I have sitting there. Install went fine, restarted box, boot from hard drive. I get the little white Ubuntu symbol on a black screen and then a black screen with un-occupied white tool bars at top and bottom of screen and a functional mouse pointer, then nothing. It freezes there.

If I restart by holding the power switch in it occasionally shows multiple CPU overtemp messages and freezes with totally black screen. I can run the CD live and everything works like a champ. I'm going to like Ubuntu once I have this sorted out. If I boot from CD and choose the run from first hard drive option, everything loads and works fine. I was able to remove CD, update and save preferences, etc..

On one occasion, I was able to restart and boot from hard drive and it worked fine but usually it freezes at previously mentioned black screen with white bars top and bottom with mouse pointer. Please excuse my ignorance as I have very little knowledge of the inside workings of computers. I didn't even know about burning ISO's or changing boot orders until reading online. For what it's worth, the computer worked fine with no known hardware problems when it was running XP. It also is completely stock with no mods or added/replaced hardware.

View 4 Replies View Related

Programming :: Bash : Searching For Info And Changing The Color Of Keywords In The Results?

May 5, 2011

(bare with me as I am sort of new with scripting) I am trying to figure out how to run a script that does a basic chkconfig and to get only those services that are running, but changing the color of "on" to red in my output file. Here is what I am working with so far:

Quote:

#/bin/bash
RED=$(tput setaf 1)
BLK=$(tput setaf 0)

[code]....

*I had to substitute a "-" and <colon_symbol> for ":" in front of the on's, because the forum thought they were smiley faces (i.e. n) how to make the "on" to be red while the rest of everything remains in black text. I have been trying to read up on sed and awk, but it is still pretty much a mystery to me right now. There will be other things in the output file that I wouldn't want a rogue "on" to be in red, so just the instances of "on" in that one chkconfig return.

View 4 Replies View Related

Ubuntu Multimedia :: When Will VLC 1.1.10 Hits Natty

Jun 8, 2011

When vlc 1.1.10 hits natty, this is a minor security and bugs update so it should arrive soon officially?

View 5 Replies View Related

Programming :: Code For Few Warning Messages?

Oct 2, 2010

For the following compilation warning message I need to create some sample program in C for self study. Also I am looking for some good web link where all the C warnings are described.

1. Warning #47: incompatible redefinition of macro "entity" . Undefine macro before
2. Warning #167: argument of type is incompatible with parameter of type
3. Warning #175: subscript out of range

[code]....

View 1 Replies View Related

Programming :: Get The Log (syslog) Messages Through Application?

Mar 30, 2009

I want read the log messages to my 'c' application , i am using the fedora core 8 operating system , how to read the system log messages(syslog) through my application.

View 3 Replies View Related

Networking :: See Whether Wget Can Be Used To Generate Actual Url Hits On A Webpage?

Jan 16, 2011

I am trying to see whether wget can be used to generate actual url hits on a webpage. This does not look good so far�. I changed the following lines in /etc/wgetrc to:

Code: http_proxy=http : / /<proxy_ip>:<port>/ use_proxy on Output :

Code: root# wget -c <url>/ > /dev/null
--2011-01-16 12:26:38-- <url>
Connecting to <proxy_ip>:<port>... connected.

[code]....

2011-01-16 12:26:39 (88,9 KB/s) - `index.html.3' saved [50548] This does NOT generate a hit on the actual web page! It does not seem like the, > /dev/null part is working either... How can I get this to work?

View 4 Replies View Related

General :: Script To Tar Up Files When A Partition Hits A Certain Use Percentage

Apr 19, 2011

I am in need to create a script that queries how large a partition is and when it hits a certain percentage (say 90%) it will execute another script that tars up certain files (or they could just be part of the same script). I would create a cronjob that runs this script once a day.

I have the script that tars up the files I need, sets permissions, etc. (btw, the files in question are audit logs). I just need the part that runs something like a df -h and takes the use percentage of the /var partition in that query and if that percentage is greater than/ equal to 90%, it kicks off the tar script.

Here is a sniplet of the df -h with just the /var partition shown:

Quote:

So, when the cronjob sees that the Use% is >= 90%, it would kick off the tar script...if not above 90%, it closes.

View 14 Replies View Related

General :: Grep: Return An User Message When No Hits?

Jun 13, 2011

I have ASCII files to parse that 48 hours old or more ; I can identify them like so

Code:
find . -name "FILE*TXT" -mtime +1 -exec ls -ltas '{}' ';'

Some files have a list of hardware errors (we test electronic components), some have none. If the file name has no errors, I still want to display a message like so

Code:
grep ^err R*VER && echo "No error"
FILEA.TXT:err->USB3910err
FILED.TXT:err No Error

This grep statement works but it seemingly overrides the find() statement above if I run both at the same time... How can I combine the two statements to create a report that lists the filename and error(s) like so

Code:
FILEA.TXT Button3320err
FILEB.TXT USB3235err
FILEC.TXT IR Remote2436err
FILED.TXT No error

Is it possible to return "No error" with the file name without error?

View 11 Replies View Related

Slackware :: Lazy Kernel Compiler Hits Snag?

Feb 22, 2010

I haven't recompiled ny kernel in a while, but whenever I did it, it was all pretty easy. Make menuconfig; (adjust); make && make modules_install, and copy over bzImage in */arch/* and System.map to /boot and stick in new entry into grub menu.lst.However, this time, I must be missing something, because I get kernel panic on booting up to the new kernel. Is there a step I'm missing?Certainly, I was looking in /etc/rc.d and there is a rc.modules<kernelver> script in there. I wondered if I need make a new one ... although when I looked over it, it seem only to be required when forcing particular modules.

View 14 Replies View Related

Programming :: Block Messages On A Message Queue ?

Dec 3, 2010

I'm facing a scenario in which i need to block messages from being passed onto a message queue when my code is running. how to proceed.

View 8 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved