nlgma Posted July 18, 2007 Posted July 18, 2007 1st let me start off by saying I love AutoIt 3! ok, Now I'm having to use Linux etch 4.0 at work and I need to encrypt the firewall logs daily. Right now I manauly do them (gpg -encrypt companykey file.gpg) I know if it was a win box I'd use autoit to script a daemon to do it. expandcollapse popupIf FileExists ($firewall&"\logs\") Then $search = FileFindFirstFile($errors&"\error logs\*") $n = "." $nn = ".." While 1 $file = FileFindNextFile($search) if $file = $n Then ContinueLoop EndIf if $file = $nn Then ContinueLoop EndIf if $file = "" Then exitloop EndIf ;PGP file -encrypt here / move to diff location for archive WEnd FileClose($search) Else MsgBox (64,"Error" ,"Error") EndIf so basically I need to convert this to bash. Any takers ?
fu2m8 Posted July 18, 2007 Posted July 18, 2007 1st let me start off by saying I love AutoIt 3! ok, Now I'm having to use Linux etch 4.0 at work and I need to encrypt the firewall logs daily. Right now I manauly do them (gpg -encrypt companykey file.gpg) I know if it was a win box I'd use autoit to script a daemon to do it. expandcollapse popupIf FileExists ($firewall&"\logs\") Then $search = FileFindFirstFile($errors&"\error logs\*") $n = "." $nn = ".." While 1 $file = FileFindNextFile($search) if $file = $n Then ContinueLoop EndIf if $file = $nn Then ContinueLoop EndIf if $file = "" Then exitloop EndIf ;PGP file -encrypt here / move to diff location for archive WEnd FileClose($search) Else MsgBox (64,"Error" ,"Error") EndIf so basically I need to convert this to bash. Any takers ? Definately doable but not up to par with bash myself (not yet ). Plenty of bash scripting resources out there though and my fav atm is http://linuxcommand.org/ might have something useful to get you started.
nlgma Posted July 18, 2007 Author Posted July 18, 2007 Here's where I'm stuck # ls /usr/sbin/firewall/logs/ Company001_FirewallLog_2007.07.17_23:47:10_2007.07.17_23:30:05.log Company001_FirewallLog_2007.07.17_23:47:10_2007.07.18_23:48:16.log Company001_FirewallLog_2007.07.17_23:47:10_2007.07.19_23:23:23.log Company001_FirewallLog_2007.07.17_23:47:10_2007.07.20_23:14:12.log Company001_FirewallLog_2007.07.17_23:47:10_2007.07.21_23:08:45.log I just need one line at a time . IE # ls /usr/sbin/firewall/logs/ Company001_FirewallLog_2007.07.17_23:47:10_2007.07.17_23:30:05.log current .sh file #!/bin/bash file=/usr/sbin/firewallLog/settings #file path of belial.settings # Define variables logdir=$(cat $file | grep logdir= | cut -d= -f2) templog=$(cat $file | grep templog= | cut -d= -f2) errorlog=$(cat $file | grep errorlog= | cut -d= -f2) companyID=$(cat $file | grep companyID= | cut -d= -f2) error=$(cat $file | grep error= | cut -d= -f2) #Quick check to ensure files exist. file1=$(ls /usr/sbin/firewall/logs/ | grep -cl 1) # <-- where I'm stuck. Keeps listing all the files if [ -f $fil1e ]; then echo 'Working: ' else echo 'Alert: ' fi
nlgma Posted July 18, 2007 Author Posted July 18, 2007 (edited) Sweet! #!/bin/bash DIR="/usr/sbin/firewall/logs/" COUNT=0 find $DIR -type f -name "*.log" | while read FILE; do let COUNT=COUNT + 1 echo "File #"$COUNT" found: " $FILE gzip $FILE done Thanx Edited July 18, 2007 by nlgma
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now