sunhux
asked on
Help with troubleshooting a Bash Shell script : variable not printed
In the script further below (sorry my browser currently can't attach file due to some issue), the line
below (which is supposed to increment/count the number of files scanned) did not output anything
to the logfile update.log. What happened?
echo "$var "files have been checked." >> /opt/avscan/update.log
I insert the line below because for every file the scanner scanned, it output one line that contains
these strings to update.log causing update.log to become too big:
... $scanfile -NC -l=/opt/avscan /tmp/scan |grep -v "libvsapi.so" |grep -v "+-------" |grep -v " | " |grep -v "been check" >> ...
======================= Shell script to run AV scan ========================== ========
var=0
for scanfile in `find /* -type f -size -52428800c -print |grep -v ".sock" |grep -v "/cdrom" |grep -v "/boot" |grep -v "/platfo" |grep -v "/proc" |grep -v mnttab |grep -v "/sys" |grep -v "/dev" |grep -v "/net" |grep -v ".dbf" |grep -v ".arc" |grep -v ".lock" |grep -v ".ctl" |grep -v ".rdo" |grep -v "racle" |grep -v "ysql" |grep -v sulog |grep -v syslog |grep -v messages `; do
((var=var+1))
cd /opt/avscan; nice ./vscan -p=/opt/avscan $scanfile -NC -l=/opt/avscan /tmp/scan |grep -v "libvsapi.so" |grep -v "+-------" |grep -v " | " |grep -v "been check" >> /opt/avscan/update.log 2>> update.log
done
echo "$var "files have been checked." >> /opt/avscan/update.log
echo "Scan completed on " `date` >> /opt/avscan/update.log
echo "===================" >> /opt/avscan/update.log
below (which is supposed to increment/count the number of files scanned) did not output anything
to the logfile update.log. What happened?
echo "$var "files have been checked." >> /opt/avscan/update.log
I insert the line below because for every file the scanner scanned, it output one line that contains
these strings to update.log causing update.log to become too big:
... $scanfile -NC -l=/opt/avscan /tmp/scan |grep -v "libvsapi.so" |grep -v "+-------" |grep -v " | " |grep -v "been check" >> ...
======================= Shell script to run AV scan ==========================
var=0
for scanfile in `find /* -type f -size -52428800c -print |grep -v ".sock" |grep -v "/cdrom" |grep -v "/boot" |grep -v "/platfo" |grep -v "/proc" |grep -v mnttab |grep -v "/sys" |grep -v "/dev" |grep -v "/net" |grep -v ".dbf" |grep -v ".arc" |grep -v ".lock" |grep -v ".ctl" |grep -v ".rdo" |grep -v "racle" |grep -v "ysql" |grep -v sulog |grep -v syslog |grep -v messages `; do
((var=var+1))
cd /opt/avscan; nice ./vscan -p=/opt/avscan $scanfile -NC -l=/opt/avscan /tmp/scan |grep -v "libvsapi.so" |grep -v "+-------" |grep -v " | " |grep -v "been check" >> /opt/avscan/update.log 2>> update.log
done
echo "$var "files have been checked." >> /opt/avscan/update.log
echo "Scan completed on " `date` >> /opt/avscan/update.log
echo "===================" >> /opt/avscan/update.log
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'll test it out tomorrow
ASKER
So Ozo's right, it should be:
echo "$var files have been checked." >> /opt/avscan/update.log