LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 01-17-2009, 09:32 AM   #1
edpatterson
LQ Newbie
 
Registered: Aug 2003
Location: Florida
Distribution: Ubuntu
Posts: 12

Rep: Reputation: 0
Scripting ?, determine file type, compress, split and email


Source Aventail log files
Destination my email account

I do not have directed access to the Aventail servers or this would be easy. Inside of /var/log/aventail there are 10 files, one each for the last 10 days. They follow the standard .0, .1, .2 format so I am assuming they are not compressed. I would rather not assume but check the file type using file then compress them into 2 meg gz files and have them mailed.

Does anyone have a generic script that does something close to this? I think I can figure it out if I am pointed in the right direction.

file to determine file type
gzip to compress the file(s) (assuming it have a length argument)
command line like blat to send the mail.
Repeat for each server, currently 5

Thanks,
Ed
 
Old 01-17-2009, 10:24 AM   #2
David the H.
Bash Guru
 
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian sid + kde 3.5 & 4.4
Posts: 6,823

Rep: Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960Reputation: 1960
Here's a simple framework to start you out:

Code:
for FILE in /var/log/aventail/*; do

   case "$(file $FILE)" in

        *text* ) command1 $FILE | command2 ; command3 ;;

        * ) echo "not a text file" ;;

   esac

done
This will loop through all the files in the directory and test the output of file for the string "text", and runs the command1-3 string if it finds it, or echos an error if it doesn't. You'll have to shove this into another loop if you want it to check multiple servers.

If you need general scripting help there are lots of good bash scripting tutorials available on the net. The Advanced Bash Scripting Guide is one of the best.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Scripting ?, determine file type, compress, split and email edpatterson Linux - Newbie 2 01-17-2009 10:40 AM
Split large file in several files using scripting (awk etc.) chipix Programming 14 10-29-2007 11:16 AM
Compress and split a big sized file into smaller files hicham007 Programming 3 07-28-2005 08:56 PM
How do I determine file system type? lowpro2k3 Linux - General 5 07-09-2005 03:40 PM
How does KDE determine file type? vdemuth Linux - Software 4 01-08-2005 04:08 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 08:17 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration