Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

shell script help 2

Status
Not open for further replies.

scooter6

IS-IT--Management
Jul 10, 2001
44
US
I am needing to write a script that will allow me to do the following:

I am running on SCO OpenServer 5.0.4

I have over 25 servers on my network...

Currently, once an our, I get logdata files from each of the servers and 'cat' them together if they have the same application ID (i.e. all the 'art0528.mmdd' files are cat together to create one log file for that application.

What I want to do sometime right after midnight, is write a script to look at all the similar files on each server as mentioned above and make sure my "cat" file is equal to the size of ALL the individual files for that day.

I hope that makes sense. In a nutshell, if server 1 has
art0528.0710 with a file size of 3241 ; and server 2 has
art0528.0710 with a file size of 1168 ; then, at the end of
the day, two things will have occurred: (1) the files will still INDIVIDUALLY be on the respective server they originated from; (2) I will have a "cat-ted" file that will be on a separte server that will be : art0528.0710 with a file size of 4409 (the same as the two individual files combined)

Thus, I need a script that will look at all the "cat-ted" files at the end of the day and make sure that file size matches the total of all the individual file sizes from all the servers.

Thanks for any assistance anyone out there can give me.

sullmann@telespectrum.com
 
Sounds pretty sinple - use "wc" and specify "-l" for lines, or "-c" for characters, or "-b" for bytes.

Bill.
 
I can get that far...but, I then need to know how to write a "compare" script to compare the total line that the
"wc" command gives me versus the total of the 1 file I end up with at the end of the day.

For example, on SCO, if I do a wc -m art* it will give me
the individual files listed with a total line at the end.
I need to write a script that compares that "total" line to the ONE file that has been "cat-ted" for the day and make sure they match.

Thanks again
 
#!/usr/bin/ksh

f1=`wc -m art*|tail -1|awk {'print $1'}`
f2=`wc -m combofile|tail -1|awk {'print $1'}`

if [ "$f1" -ne "$f2" ] ; then
echo "Files do not appear to be the same"
exit 1
fi
 
Thanks bjverzal....sorry...it was a long day...

I'll give that a shot tomorrow morning...

I appreciate it.....heehe....I'm getting old :(
 
Hi,

no idea if your applications are able to log to "syslogd" instead of logging to a file, but that way its much easier to collect all logging data on "@loghost" without the need of cronjobs...

ciao, mbr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top