i already use AVG, so i'm familiar with it. the only issue i'm having with this script is it wont scan the items, even though the scan log shows the proper command as recognised, and the process as completed, with zero items scanned.
same results regardless of spaces in paths and how many scan locations. i also tried the same command (that scan log recognised), including the extra spaces between parts, directly in the terminal, it did not give the error!
i'm out of ideas as to why the scan log gives this error "Object scan failed. Specified file was not found" and doesnt scan the items, at least for some folders.
Code: Select all
#!/bin/bash
echo -ne "\e[8;009;079t"
echo -ne "\033]0;AVG Custom Scan\007"
logfile="$HOME/.AVG custom scan.log"
: > "$HOME/.temp_scan_locations.txt"
# Query and set scan locations
while true; do
clear
echo -ne "\e[1m\e[34m"
echo
echo -e " Copy and paste a full folder path to scan. "
echo -e " Example: /media/username/USB Drive "
echo
echo -e " Or type C to continue "
echo
echo
echo -ne "\e[0m"
echo -n " "; read answer
# When input is a scan location
if echo "$answer" | grep -q '^/'
then
echo -n " $answer" >> "$HOME/.temp_scan_locations.txt"
# When input indicates to continue
elif [ "$answer" = "c" ]
then
break
# When input is neither of the above
else
clear
echo -ne "\e[1m\e[34m"
echo
echo -e " Please try again... "
echo -ne "\e[0m"
sleep 3
fi
done
clear
echo -ne "\e[1m\e[34m"
sudo echo
setterm -cursor off
echo -ne "\e[8;005;030t"
clear
# Run in background so it constantly displays
{
echo -ne "\e[1m\e[34m"
echo
echo -e " Scanning... "
echo -ne "\e[0m"
} &
# Dont show output in terminal
{
# Start AVG daemons
sudo /etc/init.d/avgd start
# Update definitions
sudo avgupdate
# Start timer
start=$SECONDS
# Scan
avgscan -aPcijk -r "$logfile" "$(cat $HOME/.temp_scan_locations.txt)"
# End timer
minutes_passed=$(( (SECONDS - start) / 60 ))
remainder=$(( (SECONDS - start) % 60 ))
rm "$HOME/.temp_scan_locations.txt"
infections=$(tail -n 8 "$logfile" \
| grep Infections \
| cut -d" " -f6 | cut -d'(' -f1)
pups=$(tail -n 8 "$logfile" \
| grep PUPs \
| cut -d" " -f12)
warnings=$(tail -n 8 "$logfile" \
| grep Warnings \
| cut -d" " -f5)
# If there are any warnings, PUPs, or supposed infections
if [ $warnings -ne 0 ] ||
[ $pups -ne 0 ] ||
[ $infections -ne 0 ]
then
# Pop-up notification
notify-send "Possible malware found, opening details" \
"Scan took $minutes_passed min. $remainder sec." \
-t 36000000 -u critical
sleep 4
# Open results log file
mv "$logfile" "$logfile".old; sleep 2
nohup gedit "$logfile".old &
sleep 5
else
notify-send "No malware found" \
"Scan took $minutes_passed min. $remainder sec." \
-t 36000000 -u critical
fi
} > /dev/null 2>&1
exit
Edit:
tidied the code, but the scan issue remains.